I just upgraded Unity3D from 4.1 to 4.3. I have a working project, and it doesnt work after the upgrade. The reason is a gameobject seems to be destroyed after I change the scene. Here is some codes:
public class GameDataObject:Object {
public string name;
}
public class GameMainScript:MonoBehaviour {
public static GameMainScript mainScript;
public GameDataObject gameDataObject;
void Start() {
gameSataObject = new GameDataObject();
gameDataObject.name = "ABC";
DontDestroyOnLoad(gameDataObject);
Application.LoadLevel("NewScene");
}
}
In NewScene, I have a script:
Debug.Log(GameMainScript.mainScript.gameDataObject.name);
It shows “ABC” in Unity 4.1, but now in Unity 4.3, it shows “”.
Any idea? Thanks