So I have an overridden graph derived from GridGraph soley for the prupsoe of adding the following method:
public override void UpdateNodePositionCollision(GridNode node, int x, int z, bool resetPenalty = true) {
base.UpdateNodePositionCollision(node, x, z, resetPenalty);
// no nodes below sealevel
if (node.position.y <= Terrain.activeTerrain.seaLevel) {
node.Walkable = false;
}
}
(btw, is that the correct way to do what I want?) Anyways…
I need to create the editor class so I can select this, but I want to be able to have all the optiosn from gridgraph. I tried this:
[CustomGraphEditor(typeof(TerrainGraph), "Terrain Graph")]
public class TerrainGraphEditor : GridGraphEditor {
// Here goes the GUI
public void OnInspectorGUI(TerrainGraph target) {
base.OnBaseInspectorGUI((GridGraph)target);
//TerrainGraph graph = (TerrainGraph)target;
}
}
But I get a the following exception when I add the graph:
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.GridGraphEditor.OnSceneGUI (Pathfinding.NavGraph target) (at Assets/ThirdParty/AstarPathfindingProject/Editor/GraphEditors/GridGeneratorEditor.cs:477)
AstarPathEditor.OnSceneGUI () (at Assets/ThirdParty/AstarPathfindingProject/Editor/AstarPathEditor.cs:858)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:232)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object parameters) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MethodBase.cs:115)
UnityEditor.SceneView.CallOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:2056)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1405)
UnityEditor.SceneView.OnGUI () (at C:/buildslave/unity/build/Editor/Mono/SceneView/SceneView.cs:1242)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)
Is it possible to do what I want to do? Better yet, is there a way to hook into the code that checks if a node is walkable without having to create a bunch of new classes?
EDIT:
So I fixed some stupid things I was doing (like not actually expanding the graph in the inspector), and I see everything from GridGraph. However I still have this exception whenever I view the inspector.