“InvalidOperationException: Graphs cannot be added, removed or serialized while the graph structure is locked. This is the case when a graph is currently being scanned and when executing graph updates and work items.
However as a special case, graphs can be added inside work items.”
When I try to RemoveGraph during a OnDestroy of a game object. It is a similar use case to the one mentioned fro Badjano in the separate thread, only the graph isn’t getting destroyed during a scene unload, but instead, the graph is being destroyed when I destroy a game object.
OnDestroy()
{
AstarData data = AstarPath.active.data;
if ( m_OwnerOfGridGraphInstance )
{
data.RemoveGraph ( m_GridGraph );
}
}
Would wrapping the data.RemoveGraph in a AddWorkItem/AstarWorkItem request solve the issue?
I didn’t see your reply until after I had already spent time testing this For what it’s worth, I got it to delete without using a work item, but that’s probably down to the simplistic nature of my testing environment.