Quantcast
Channel: Questions in topic: "dontdestroyonload"
Viewing all articles
Browse latest Browse all 416

Unity 5.6.0f2 Don't destroy on load duplicate

$
0
0
Hello! I have a problem. Here is some code samples: public static Inventory instance { get; set; } private void Awake() { if (instance == null) { instance = this; } else { DestroyObject(gameObject); } DontDestroyOnLoad(this); } public static Inventory instance { get; set; } private void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); } DontDestroyOnLoad(this); } One of these codes is working, and the other is not. I do not know what the problem is and I want to know. The official guide says that you need to use the Destroy method but it does not work for me. I use the DestroyObject method instead Destroy and it's work fine. Who can explain why this happens?

Viewing all articles
Browse latest Browse all 416

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>