blob: bedf8b84f4224c97bd4b086bf71695aeb5997b98 (
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
|
using UnityEngine;
using UnityEditor;
using Pathfinding.Graphs.Grid;
namespace Pathfinding {
[CustomGraphEditor(typeof(LayerGridGraph), "Layered Grid Graph")]
public class LayerGridGraphEditor : GridGraphEditor {
protected override void DrawMiddleSection (GridGraph graph) {
var layerGridGraph = graph as LayerGridGraph;
DrawNeighbours(graph);
layerGridGraph.characterHeight = EditorGUILayout.DelayedFloatField("Character Height", layerGridGraph.characterHeight);
DrawMaxClimb(graph);
DrawMaxSlope(graph);
DrawErosion(graph);
}
protected override void DrawMaxClimb (GridGraph graph) {
var layerGridGraph = graph as LayerGridGraph;
base.DrawMaxClimb(graph);
layerGridGraph.maxStepHeight = Mathf.Clamp(layerGridGraph.maxStepHeight, 0, layerGridGraph.characterHeight);
if (layerGridGraph.maxStepHeight >= layerGridGraph.characterHeight) {
EditorGUILayout.HelpBox("Max step height needs to be smaller or equal to character height", MessageType.Info);
}
}
protected override void DrawCollisionEditor (GraphCollision collision) {
base.DrawCollisionEditor(collision);
if (collision.thickRaycast) {
EditorGUILayout.HelpBox("Note: Thick raycast cannot be used with this graph type", MessageType.Error);
}
}
protected override void DrawUse2DPhysics (GraphCollision collision) {
// 2D physics does not make sense for a layered grid graph
collision.use2D = false;
}
}
}
|