- Home /
Multiple error without line number
I keep getting strange errors and I don't know why, there isn't line number so I could find them in script. And script works fine.... How can I fix them?
ScreenShot: http://www.dodaj.rs/f/1b/yG/3u1jsWSm/capture.png
Example of error:
UnityException: You are not allowed to call this function when declaring a variable.
Move it to the line after without a variable declaration.
If you are using C# don't use this function in the constructor or field initializers, Instead move initialization to the Awake or Start function.
UnityEngine.GameObject..ctor () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:328)
NewBehaviourScript..ctor ()
Another example:
ArgumentException: Internal_CreateGameObject 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.
UnityEngine.GameObject..ctor () (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineGameObject.cs:328)
NewBehaviourScript..ctor ()
Try double-clicking the error message, it should get you to the error's source.
Also, it seems like you are trying to dabble with GameObject/Component constructors - don't. These should be created using instantiate, not new.
You can also run into this issue doing things like
public myGameObject = new GameObject();
$$anonymous$$ake sure you don't try to instantiate anything at the same point you're declaring it. $$anonymous$$ove instantiations and component additions / creations into, say Start() or Update().