您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
56 行
1.2 KiB
56 行
1.2 KiB
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
public class PathwayGizmos
|
|
{
|
|
[DrawGizmo(GizmoType.Selected)]
|
|
private static void DrawGizmosSelected(Pathway pathway, GizmoType gizmoType)
|
|
{
|
|
|
|
DrawHandlesPath(pathway);
|
|
}
|
|
|
|
private static void DrawElements(Pathway pathway, List<Vector3> path, int index)
|
|
{
|
|
GUIStyle style = new GUIStyle();
|
|
Vector3 textHeight = Vector3.up;
|
|
|
|
style.normal.textColor = pathway.TextColor;
|
|
style.fontSize = pathway.TextSize;
|
|
|
|
Handles.Label(path[index] + textHeight, index.ToString(), style);
|
|
}
|
|
|
|
private static void DrawHandlesPath(Pathway pathway)
|
|
{
|
|
if (pathway.Waypoints.Count != 0)
|
|
{
|
|
DrawElements(pathway, pathway.Waypoints, 0);
|
|
}
|
|
|
|
for (int i = 0; i < pathway.Waypoints.Count; i++)
|
|
{
|
|
if (i != 0 && pathway.Waypoints.Count > 1)
|
|
{
|
|
DrawElements(pathway, pathway.Waypoints, i);
|
|
using (new Handles.DrawingScope(pathway.LineColor))
|
|
{
|
|
Handles.DrawDottedLine(pathway.Waypoints[i - 1], pathway.Waypoints[i], 2);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
if (pathway.Waypoints.Count > 2)
|
|
{
|
|
using (new Handles.DrawingScope(pathway.LineColor))
|
|
{
|
|
Handles.DrawDottedLine(pathway.Waypoints[0], pathway.Waypoints[pathway.Waypoints.Count - 1], 2);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|