49 lines
1.1 KiB
C#
49 lines
1.1 KiB
C#
|
#if UNITY_EDITOR
|
|||
|
using System.IO;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEditor;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
|
|||
|
namespace Thousandto.Editor.Test
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 地形切割工具的辅助类,用于显示各种标线
|
|||
|
/// </summary>
|
|||
|
[UnityEditor.CustomEditor(typeof(DrawGizmos))]
|
|||
|
public class DrawGizmos : MonoBehaviour
|
|||
|
{
|
|||
|
private List<Action> _actions;
|
|||
|
|
|||
|
|
|||
|
void OnDrawGizmos()
|
|||
|
{
|
|||
|
if (_actions == null)
|
|||
|
return;
|
|||
|
for(int i = 0; i < _actions.Count; ++i)
|
|||
|
{
|
|||
|
if (_actions[i] != null)
|
|||
|
_actions[i]();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void AddAction(Action action)
|
|||
|
{
|
|||
|
if (_actions == null)
|
|||
|
_actions = new List<Action>();
|
|||
|
|
|||
|
_actions.Add(action);
|
|||
|
}
|
|||
|
|
|||
|
public void RemoveAction(Action action)
|
|||
|
{
|
|||
|
if (_actions == null)
|
|||
|
return;
|
|||
|
|
|||
|
if (_actions.IndexOf(action) > 0)
|
|||
|
_actions.Remove(action);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endif
|