浏览代码

Cleaned up + Protect waypoint inputs from updated by NavMesh

/main
Yohann Puyhaubert 4 年前
当前提交
785fcec4
共有 2 个文件被更改,包括 21 次插入25 次删除
  1. 7
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayEditor.cs
  2. 39
      UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayGizmos.cs

7
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayEditor.cs


_reorderableList.drawElementCallback += DrawElement;
_reorderableList.onAddCallback += AddItem;
_reorderableList.onRemoveCallback += RemoveItem;
_reorderableList.onSelectCallback += SelectItem;
_reorderableList.onChangedCallback += ListModified;
_pathway = (target as PathwayConfigSO);
if (CheckNavMeshExistence())

_reorderableList.drawElementCallback -= DrawElement;
_reorderableList.onAddCallback -= AddItem;
_reorderableList.onRemoveCallback -= RemoveItem;
_reorderableList.onSelectCallback -= SelectItem;
_reorderableList.onChangedCallback -= ListModified;
SceneView.duringSceneGui -= this.OnSceneGUI;
}

list.index--;
}
}
private void SelectItem(ReorderableList list)
{
InternalEditorUtility.RepaintAllViews();
}
private void ListModified(ReorderableList list)

39
UOP1_Project/Assets/Scripts/Editor/Pathway/PathwayGizmos.cs


{
EditorGUI.BeginChangeCheck();
List<Vector3> pathwayEditorDisplay = new List<Vector3>();
pathway.Waypoints[i] = hit.position;
pathwayEditorDisplay.Add(hit.position);
}
// Only one waypoint use case.

pathway.Waypoints[0] = Handles.PositionHandle(pathway.Waypoints[0], Quaternion.identity);
}
// All the other use cases where a path exists.
else if (pathway.Waypoints.Count > 1)
for (int index = 0; index < pathway.Waypoints.Count && pathway.Waypoints.Count > 1; index++)
for (int index = 0; index < pathway.Waypoints.Count && pathway.Waypoints.Count > 1; index++)
int nextIndex = (index + 1) % pathway.Waypoints.Count;
DrawWaypointLabel(pathway, pathway.Waypoints, index);
List<Vector3> navMeshPath = new List<Vector3>();
NavMeshPath navPath = new NavMeshPath();
NavMesh.CalculatePath(pathwayEditorDisplay[index], pathwayEditorDisplay[nextIndex], NavMesh.AllAreas, navPath);
using (new Handles.DrawingScope(pathway.LineColor))
int nextIndex = (index + 1) % pathway.Waypoints.Count;
DrawWaypointLabel(pathway, pathway.Waypoints, index);
List<Vector3> navMeshPath = new List<Vector3>();
NavMeshPath navPath = new NavMeshPath();
NavMesh.CalculatePath(pathway.Waypoints[index], pathway.Waypoints[nextIndex], NavMesh.AllAreas, navPath);
using (new Handles.DrawingScope(pathway.LineColor))
for (int j = 0; j < navPath.corners.Length - 1; j++)
for (int j = 0; j < navPath.corners.Length - 1; j++)
{
Handles.DrawDottedLine(navPath.corners[j], navPath.corners[j + 1], 2);
}
Handles.DrawDottedLine(navPath.corners[j], navPath.corners[j + 1], 2);
// Display handles pointing into the path forward direction (Blue handle)
if (navPath.corners.Length > 1)
{
pathway.Waypoints[index] = Handles.PositionHandle(pathway.Waypoints[index], Quaternion.LookRotation(navPath.corners[1] - navPath.corners[0]));
}
}
// Display handles pointing into the path forward direction (Blue handle)
if (navPath.corners.Length > 1)
{
pathway.Waypoints[index] = Handles.PositionHandle(pathway.Waypoints[index], Quaternion.LookRotation(navPath.corners[1] - navPath.corners[0]));
}
else
{
pathway.Waypoints[index] = Handles.PositionHandle(pathway.Waypoints[index], Quaternion.identity);
}
}
}

正在加载...
取消
保存