CompareBaseObjectsInternal error updating graphs

Hi, I’m using unity 4.3 and A* 3.3.10. I have a recast graph on some procedural terrain which is started via script by AstarPath.active.Awake();. This works fine and my seeker moves around. However, if I modify the terrain dynamically and try to update it for A* by using:

Bounds currentBounds = new Bounds (transform.position, new Vector3 (4, 4, 4));
AstarPath.active.UpdateGraphs(currentBounds, 1);

I get two errors:

CompareBaseObjectsInternal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.

Exception while updating graphs:
System.ArgumentException: CompareBaseObjectsInternal can only be called from the main thread.
Constructors and field initializers will be executed from the loading thread when loading a scene.
Don’t use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
at (wrapper managed-to-native) UnityEngine.Object:CompareBaseObjectsInternal (UnityEngine.Object,UnityEngine.Object)
at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs)

I’ve tried turning off multithreading and pretty much all the other optimizations that look relevant. Any idea?

Hm…

So it looks like the recast graph updater is trying to access unity objects from another thread.
Updates to recast graphs are being run in another thread, but I thought I made sure that all access to Unity stuff is done in the Unity thread…

Is there any way you can get a more exact stacktrace from it?

As a quick fix, open the RecastGenerator.cs file and edit the CanUpdateAsync method.
It should return GraphUpdateThreading.UnityThread instead of GraphUpdateThreading.SeparateAndUnityInit.