- Home /
Tracking down causes of Editor errors.
Is there a way to track down the errors that the editor gives that don't have callstacks?
Specifically I'm getting the errors:
CConstructors and field initializers will be executed from the loading thread when loading a scene.ompareBaseObjects can only be called from the main thread.
Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
Can't destroy Transform component. If you want to destroy the game object please call 'Destroy' on the game object instead. Destroying the transform component is not allowed.
The only other information that these errors provide is the Unity internal source file that caused the errors:
c:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cpp at line: 19
c:/BuildAgent/work/812c4f5049264fad/Runtime/Misc/GameObjectUtility.cpp at line: 1011
I've searched my code and haven't been able to follow the advice in the errors. Is there any additional information that can be gleaned? The editor log doesn't provide any more information. I know that my scripts are the source of the problem but I need to narrow down the problem before I can fix it.
Are you using a dll or are you using a thread or any class that might use threads (e.g. C# timer)?
If so, make sure, you do not call anything related to Unity API from within that thread.
I am using some 3rd party dlls so I can't speak to what they're doing internally. But I first question my own code when looking for bugs.
As for my own threading, I make sure that I'm not using any Unity APIs from separate threads.
Answer by ivarboms · Feb 07, 2013 at 09:59 AM
You can use MonoDevelop to help tracking down errors like this, at least if they're caused by exceptions being thrown. Unfortunately Unity will often only log a debug message when an error occurs rather than throwing an exception.
To debug exceptions, do the following: In MonoDevelop, open Run->Exceptions, and move all the exceptions except for UnityEngine.ExitGUIException to the "Stop in exceptions" window. Now attach MonoDevelop to the Unity editor and enter play mode. MonoDevelop will now break whenever any of the exceptions are thrown, even from threads other than the main thread.
This was a pretty good idea but it didn't seem to catch the errors. I'd still catch the ExitGUIExceptions when entering/exiting playmode (I'm assu$$anonymous$$g because ExitGUIExeption inherits from System.Exception). And I'd catch a few stream related exceptions when opening logs.
The errors were not as frequent (or toggling between the debugger and unity changed the repro) but when I did eventually get the "Can't destroy Transform component" error message $$anonymous$$onodevelop hadn't caught that exception.
Also running playmode twice would cause the editor to become unresponsive and I'd have to kill it from task manager & relaunch it.