BITFALL/Assets/BITKit/UnityEditor/SceneGizmoReference.cs

35 lines
803 B
C#
Raw Normal View History

2024-02-22 16:26:51 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-03-05 17:34:41 +08:00
// ReSharper disable FieldCanBeMadeReadOnly.Global
2024-02-22 16:26:51 +08:00
namespace BITKit.Scene
{
public class SceneGizmoReference : MonoBehaviour
{
2024-03-05 17:34:41 +08:00
[Export]
public static bool AllowGizmos=true;
2024-02-22 16:26:51 +08:00
[SerializeField] private bool draw;
[SerializeField] private Color color;
[SerializeField] private float size;
[SerializeField] private Optional<Vector3> bounds;
private void OnDrawGizmos()
{
2024-03-05 17:34:41 +08:00
if (draw is false || AllowGizmos is false) return;
2024-02-22 16:26:51 +08:00
var position = transform.position;
Gizmos.color = color;
Gizmos.DrawWireSphere(position, size);
if (bounds.Allow)
{
2024-03-05 17:34:41 +08:00
var rotation = transform.rotation;
Gizmos.DrawWireCube(position+rotation*bounds.Value/2, rotation*bounds.Value);
2024-02-22 16:26:51 +08:00
}
}
}
}