- A* version: 5.3.0
- Unity version: 2022.3.55f1
I’m unsure if this is the place to report a bug, but when I’m creating layered grid graphs and I forget to set the parameters mentioned in the title, Unity freezes and won’t unlock.
I’m attaching my code, I had to run a fallback to block it from creating it.
private void GenerateGraph()
{
var graphName = $"LayerGridGraph_{SceneManager.GetActiveScene().name}";
DeleteGraph(graphName);
if (graphWidth <= 0 || graphDepth <= 0 || graphNodeSize <= 0)
{
Debug.LogError($"Graph {graphName} can't be created");
return;
}
var astarData = AstarPath.active.data;
// Create a new LayeredGridGraph
LayerGridGraph layeredGraph = astarData.AddGraph(typeof(LayerGridGraph)) as LayerGridGraph;
// Configure the Layered Grid Graph
layeredGraph.name = graphName;
layeredGraph.center = transform.position + ((graphNodeSize / 2) * new Vector3(graphWidth, 0, graphDepth)); // Center of the graph
layeredGraph.SetDimensions(graphWidth, graphDepth, graphNodeSize); // Graph dimensions
layeredGraph.collision.mask = obstacleLayerMask;
layeredGraph.collision.heightCheck = true; // Enable height checking
layeredGraph.collision.heightMask = LayerMask.GetMask("Default"); // Set collision layers
layeredGraph.maxStepHeight = 0.4f; // Max climb height between nodes
layeredGraph.collision.fromHeight = 2f; // Height from which to start raycasting for layers
// Scan the graph to bake it
layeredGraph.Scan();
Debug.Log($"Layered Grid Graph {graphName} created and scanned at runtime.");
}
So I’m not getting any freezing in my Editor, with 5.23, 5.3.0 in either 2022.3.53f1 or Unity 6. Not sure why that is, but I’m unable to recreate it on my end- for context I basically jsut copy pasted your code that creates the graph, set the numbers to 0 and tried it.
[Button]
void MakeEmptyGraph(){
var astarData = AstarPath.active.data;
// Create a new LayeredGridGraph
LayerGridGraph layeredGraph = astarData.AddGraph(typeof(LayerGridGraph)) as LayerGridGraph;
// Configure the Layered Grid Graph
layeredGraph.name = "New Graph";
layeredGraph.center = transform.position + ((0 / 2) * new Vector3(0, 0, 0)); // Center of the graph
layeredGraph.SetDimensions(0, 0, 0); // Graph dimensions
layeredGraph.collision.mask = LayerMask.GetMask("Obstacle", "Dynamic Obstacle");
layeredGraph.collision.heightCheck = true; // Enable height checking
layeredGraph.collision.heightMask = LayerMask.GetMask("Default"); // Set collision layers
layeredGraph.maxStepHeight = 0.4f; // Max climb height between nodes
layeredGraph.collision.fromHeight = 2f; // Height from which to start raycasting for layers
// Scan the graph to bake it
layeredGraph.Scan();
}
I did get an error, on all four testing environments though:
AstarPath.Scan (Pathfinding.NavGraph[] graphsToScan) (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1569)
AstarPath.Scan (Pathfinding.NavGraph graphToScan) (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1532)
Pathfinding.NavGraph.Scan () (at ./Packages/com.arongranberg.astar/Graphs/NavGraph.cs:441)
EmptyGraphMaker.MakeEmptyGraph () (at Assets/EmptyGraphMaker.cs:29)
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b0b3ee161b9b40739da01ef24d5555a8>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <b0b3ee161b9b40739da01ef24d5555a8>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <b0b3ee161b9b40739da01ef24d5555a8>:0)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer.InvokeMethodInfo (System.Reflection.MethodInfo methodInfo) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:549)
UnityEngine.Debug:LogException(Exception)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:InvokeMethodInfo(MethodInfo) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:574)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:InvokeButton() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:450)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawNormalButton() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:297)
Sirenix.OdinInspector.Editor.Drawers.DefaultMethodDrawer:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Misc Drawers/DefaultMethodDrawer.cs:195)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:841)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:729)
Sirenix.OdinInspector.Editor.Drawers.UnityObjectRootDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Value Drawers/UnityObjectRootDrawer.cs:60)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155)
Sirenix.OdinInspector.Editor.Validation.ValidationDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Validation/Core/ValidationDrawer.cs:264)
Sirenix.OdinInspector.Editor.OdinDrawer:CallNextDrawer(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:155)
Sirenix.OdinInspector.Editor.Drawers.FixBrokenUnityObjectWrapperDrawer`1:DrawPropertyLayout(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/Attribute Drawers/FixBrokenUnityObjectWrapperDrawer.cs:41)
Sirenix.OdinInspector.Editor.OdinDrawer:DrawProperty(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinDrawer.cs:109)
Sirenix.OdinInspector.Editor.InspectorProperty:Draw(GUIContent) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/InspectorProperty.cs:841)
Sirenix.OdinInspector.Editor.PropertyTree:DrawProperties() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:552)
Sirenix.OdinInspector.Editor.PropertyTree:Draw(Boolean) (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Core/PropertyTree.cs:444)
Sirenix.OdinInspector.Editor.OdinEditor:DrawTree() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:98)
Sirenix.OdinInspector.Editor.OdinEditor:DrawOdinInspector() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:232)
Sirenix.OdinInspector.Editor.OdinEditor:OnInspectorGUI() (at D:/Sirenix/Sirenix Solution/Sirenix.OdinInspector.Editor/Drawers/OdinEditor.cs:80)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
(The routing through Sirenix is because I used a button made from Odin Inspector for this, most likely unrelated) I’ll tag @aron_granberg on this to see if he may know what’s causing this, let alone the discrepancy.
1 Like
Perfect!
I’m currently OK as the workaround solves my issue.
Thanks
1 Like
Hi
I cannot replicate any freezes. But there were indeed bugs when trying to scan a graph with zero width and depth. I’ve made some fixes that will be included in the next update.