1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
using UnityEngine;
using UnityEditor;
namespace Pathfinding {
[CustomGraphEditor(typeof(NavMeshGraph), "Navmesh Graph")]
public class NavMeshGraphEditor : GraphEditor {
public override void OnInspectorGUI (NavGraph target) {
var graph = target as NavMeshGraph;
graph.sourceMesh = ObjectField("Source Mesh", graph.sourceMesh, typeof(Mesh), false, true) as Mesh;
graph.offset = EditorGUILayout.Vector3Field("Offset", graph.offset);
graph.rotation = EditorGUILayout.Vector3Field("Rotation", graph.rotation);
graph.scale = EditorGUILayout.FloatField(new GUIContent("Scale", "Scale of the mesh"), graph.scale);
graph.scale = Mathf.Abs(graph.scale) < 0.01F ? (graph.scale >= 0 ? 0.01F : -0.01F) : graph.scale;
#pragma warning disable 618
if (graph.nearestSearchOnlyXZ) {
graph.nearestSearchOnlyXZ = EditorGUILayout.Toggle(new GUIContent("Nearest node queries in XZ space",
"Recomended for single-layered environments.\nFaster but can be inacurate esp. in multilayered contexts."), graph.nearestSearchOnlyXZ);
EditorGUILayout.HelpBox("The global toggle for node queries in XZ space has been deprecated. Use the NNConstraint settings instead.", MessageType.Warning);
}
#pragma warning restore 618
graph.recalculateNormals = EditorGUILayout.Toggle(new GUIContent("Recalculate Normals", "Disable for spherical graphs or other complicated surfaces that allow the agents to e.g walk on walls or ceilings. See docs for more info."), graph.recalculateNormals);
graph.enableNavmeshCutting = EditorGUILayout.Toggle(new GUIContent("Affected by navmesh cuts", "Makes this graph affected by NavmeshCut and NavmeshAdd components. See the documentation for more info."), graph.enableNavmeshCutting);
if (graph.enableNavmeshCutting) {
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
var newValue = EditorGUILayout.FloatField(new GUIContent("Agent radius", "Navmesh cuts can optionally be expanded by the agent radius"), graph.navmeshCuttingCharacterRadius);
if (EditorGUI.EndChangeCheck()) {
graph.navmeshCuttingCharacterRadius = Mathf.Max(0, newValue);
graph.navmeshUpdateData.ReloadAllTiles();
}
EditorGUI.indentLevel--;
}
GUILayout.BeginHorizontal();
GUILayout.Space(18);
graph.showMeshSurface = GUILayout.Toggle(graph.showMeshSurface, new GUIContent("Show surface", "Toggles gizmos for drawing the surface of the mesh"), EditorStyles.miniButtonLeft);
graph.showMeshOutline = GUILayout.Toggle(graph.showMeshOutline, new GUIContent("Show outline", "Toggles gizmos for drawing an outline of the nodes"), EditorStyles.miniButtonMid);
graph.showNodeConnections = GUILayout.Toggle(graph.showNodeConnections, new GUIContent("Show connections", "Toggles gizmos for drawing node connections"), EditorStyles.miniButtonRight);
GUILayout.EndHorizontal();
}
}
}
|