I declare a bunch of variable in my path class. Code (CSharp): public static class p { static public string gamepath= Path.GetDirectoryName(UnityEngine.Application.dataPath); static public string localpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), g.GameName); readonly static public string Resourcesfull = p.Combinem(gamepath, "Assets", "Resources\\"); static public string gamesetpath = p.Combine(gamepath, "gameset\\"); There are many more variables that base on gamepath. Today i suddenly got: Code (CSharp): UnityException: get_dataPath is not allowed to be called during serialization, call it from Awake or Start instead. Called from MonoBehaviour 'execute' on game object 'script'. I did get it sometimes before but the construction worked in general. Now i have three questions: Why does it sometimes work and sometimes not? Why does unity3d insist on it not be called during serialization? What can i do now in no case i want to rewrite that variables so i need the data path during serialization?
I guess, as long as serialization goes on, it won't work. For your example, the run cycle is not always equal to the previous, so maybe it sometimes is done serializing, sometimes it is not. So you better wait for that serialization to happen before going on to the next part? just a general guess as your example does not really tell, where it happens.
I added where it is to my question. It is directly declared in the class (not in the awake or start function like unity seems to insist unity insists it must only be declared in the mainthread).