using System; using System.Collections; using System.Collections.Generic; using UnityEngine; // ReSharper disable FieldCanBeMadeReadOnly.Global namespace BITKit.Scene { public class SceneGizmoReference : MonoBehaviour { [Export] public static bool AllowGizmos=true; [SerializeField] private bool draw; [SerializeField] private Color color; [SerializeField] private float size; [SerializeField] private Optional bounds; private void OnDrawGizmosSelected() { if (draw is false || AllowGizmos is false) return; var position = transform.position; Gizmos.color = color; if (bounds.Allow) { var rotation = transform.rotation; Gizmos.DrawCube(position, rotation*bounds.Value); } RenderRay(transform.up); RenderRay(transform.forward); RenderRay(transform.right); RenderRay(-transform.right); RenderRay(-transform.up); RenderRay(-transform.forward); return; void RenderRay(Vector3 direction) { if (Physics.Raycast(position, direction, out var hit)) { Debug.DrawLine(position, hit.point, color); } } } } }