blob: ef2b625759c0d49641734aa4ca44daab07b423d9 (
plain)
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
50
51
52
53
54
55
56
57
|
using UnityEngine;
using UnityEditor;
namespace Pathfinding {
[CustomEditor(typeof(NavmeshAdd))]
[CanEditMultipleObjects]
public class NavmeshAddEditor : EditorBase {
protected override void Inspector () {
EditorGUI.BeginChangeCheck();
var type = FindProperty("type");
PropertyField("type", "Shape");
EditorGUI.indentLevel++;
if (!type.hasMultipleDifferentValues) {
switch ((NavmeshAdd.MeshType)type.intValue) {
case NavmeshAdd.MeshType.Rectangle:
PropertyField("rectangleSize");
break;
case NavmeshAdd.MeshType.CustomMesh:
PropertyField("mesh");
PropertyField("meshScale");
break;
}
}
PropertyField("center");
EditorGUI.indentLevel--;
EditorGUILayout.Separator();
PropertyField("updateDistance");
if (PropertyField("useRotationAndScale")) {
EditorGUI.indentLevel++;
FloatField("updateRotationDistance", min: 0f, max: 180f);
EditorGUI.indentLevel--;
}
EditorGUI.BeginChangeCheck();
PropertyField("graphMask", "Traversable Graphs");
bool changedMask = EditorGUI.EndChangeCheck();
serializedObject.ApplyModifiedProperties();
if (EditorGUI.EndChangeCheck()) {
foreach (NavmeshAdd tg in targets) {
tg.RebuildMesh();
tg.ForceUpdate();
// If the mask is changed we disable and then enable the component
// to make sure it is removed from the right graphs and then added back
if (changedMask && tg.enabled) {
tg.enabled = false;
tg.enabled = true;
}
}
}
}
}
}
|