155 lines
4.3 KiB
C#
155 lines
4.3 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEditor;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Serialization;
|
|||
|
|
|
|||
|
|
namespace SesothoLine
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>·<EFBFBD><C2B7><EFBFBD>Ʊ༭<C6B1><E0BCAD>
|
|||
|
|
/// </summary>
|
|||
|
|
[CustomEditor(typeof(SesothoPeManager))]
|
|||
|
|
public class SesothoPeManagerEditor : Editor
|
|||
|
|
{
|
|||
|
|
#region ί<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ǰ<EFBFBD><C7B0>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD>궯<EFBFBD><EAB6AF>
|
|||
|
|
/// </summary>
|
|||
|
|
private event Action CurrenMouseAction;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD>ֶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>DZ༭<C7B1><E0BCAD><EFBFBD><EFBFBD>ģʽ
|
|||
|
|
/// </summary>
|
|||
|
|
public bool IsDebugDrawMode;
|
|||
|
|
|
|||
|
|
private Vector3 _currentPosition;
|
|||
|
|
|
|||
|
|
private bool OpKey_ForceStr;
|
|||
|
|
private bool OpKey_90Arc;
|
|||
|
|
private bool OpKey_180Arc;
|
|||
|
|
private bool OpKey_RevCisoid;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
// private void OnEnable()
|
|||
|
|
// {
|
|||
|
|
// throw new NotImplementedException();
|
|||
|
|
// }
|
|||
|
|
//
|
|||
|
|
// private void OnDisable()
|
|||
|
|
// {
|
|||
|
|
// throw new NotImplementedException();
|
|||
|
|
// }
|
|||
|
|
|
|||
|
|
private void OnSceneGUI()
|
|||
|
|
{
|
|||
|
|
if (!IsDebugDrawMode) return;
|
|||
|
|
|
|||
|
|
int controlID = GUIUtility.GetControlID(FocusType.Keyboard);
|
|||
|
|
if(GUIUtility.hotControl == 0)
|
|||
|
|
HandleUtility.AddDefaultControl(controlID);
|
|||
|
|
|
|||
|
|
OpKey_ForceStr = false;
|
|||
|
|
OpKey_90Arc = false;
|
|||
|
|
OpKey_180Arc = false;
|
|||
|
|
OpKey_RevCisoid = false;
|
|||
|
|
|
|||
|
|
if (Event.current.GetTypeForControl(controlID) == EventType.KeyDown)
|
|||
|
|
{
|
|||
|
|
switch (Event.current.keyCode)
|
|||
|
|
{
|
|||
|
|
case KeyCode.Escape:
|
|||
|
|
IsDebugDrawMode = false;
|
|||
|
|
break;
|
|||
|
|
case KeyCode.LeftControl:
|
|||
|
|
OpKey_ForceStr = true;
|
|||
|
|
break;
|
|||
|
|
case KeyCode.LeftAlt:
|
|||
|
|
OpKey_90Arc = true;
|
|||
|
|
break;
|
|||
|
|
case KeyCode.LeftShift:
|
|||
|
|
OpKey_180Arc = true;
|
|||
|
|
break;
|
|||
|
|
case KeyCode.R:
|
|||
|
|
OpKey_RevCisoid = true;
|
|||
|
|
break;
|
|||
|
|
default:
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var mousePos = Event.current.mousePosition;
|
|||
|
|
if (Physics.Raycast(HandleUtility.GUIPointToWorldRay(mousePos), out var hit, float.MaxValue, 0xffff))
|
|||
|
|
{
|
|||
|
|
_currentPosition = hit.point;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Event.current.type == EventType.MouseUp && GUIUtility.hotControl == 0)
|
|||
|
|
{
|
|||
|
|
if (Event.current.button == 0)
|
|||
|
|
{
|
|||
|
|
CurrenMouseAction?.Invoke();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override void OnInspectorGUI()
|
|||
|
|
{
|
|||
|
|
if (GUILayout.Button(IsDebugDrawMode ? "<22>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>ģʽ" : "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ"))
|
|||
|
|
IsDebugDrawMode = !IsDebugDrawMode;
|
|||
|
|
|
|||
|
|
base.OnInspectorGUI();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|
|||
|
|
private TerminalLine2T3 _line;
|
|||
|
|
private TerminalPoint _startPoint;
|
|||
|
|
private TerminalPoint _endPoint;
|
|||
|
|
|
|||
|
|
private void DarwLine()
|
|||
|
|
{
|
|||
|
|
_endPoint.transform.position = _currentPosition;
|
|||
|
|
|
|||
|
|
// _line.SetLineSegment(
|
|||
|
|
// _lastPointPosition, _currentPosition,
|
|||
|
|
// _lastPointNormal, _helperNormal
|
|||
|
|
// );
|
|||
|
|
|
|||
|
|
|
|||
|
|
if (OpKey_ForceStr)
|
|||
|
|
_line.DrawStraightLine();
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var angle = -1;
|
|||
|
|
if (OpKey_90Arc || OpKey_180Arc)
|
|||
|
|
{
|
|||
|
|
angle = 0;
|
|||
|
|
if (OpKey_90Arc)
|
|||
|
|
angle += 90;
|
|||
|
|
if (OpKey_180Arc)
|
|||
|
|
angle += 180;
|
|||
|
|
}
|
|||
|
|
_line.AutomaticDrawCircularLine(angle, OpKey_RevCisoid);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϻ<EFBFBD>ִ<EFBFBD><D6B4><EFBFBD><EFBFBD>Ⱦ<EFBFBD><C8BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>п<EFBFBD><D0BF>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
// <20><><EFBFBD>ڴ<EFBFBD>֮ǰ<D6AE>Ľ<C4BD><D7B6>Ѿ<EFBFBD><D1BE>Դ˽<D4B4><CBBD>й<EFBFBD><D0B9>˴<EFBFBD><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>й<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>ճ<EFBFBD><D5B3>Ļ<EFBFBD><C4BB><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>һЩ<D2BB>ġ<DEB8>
|
|||
|
|
_line.UpdateRender();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
}
|
|||
|
|
}
|