This repository has been archived on 2025-06-25. You can view files and clone it, but cannot push or open issues or pull requests.
Net.Like.Xue.Tokyo/Assets/BITKit/UnityEditor/SceneGizmoReference.cs

34 lines
808 B
C#

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<Vector3> bounds;
private void OnDrawGizmosSelected()
{
if (draw is false || AllowGizmos is false) return;
var position = transform.position;
Gizmos.color = color;
Gizmos.DrawWireSphere(position, size);
if (bounds.Allow)
{
var rotation = transform.rotation;
Gizmos.DrawWireCube(position+rotation*bounds.Value/2, rotation*bounds.Value);
}
}
}
}