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

Unity Singelton - Dont destroy on load

$
0
0
Am not quiet sure what exactly is the issue in my code below. Am not able to save the game object with its component between the scene. I have created the singleton and dont destroy on load. Problem: Once I get back to the scene all the buttons and other components are not working at all. Is there any issue with my code? private static startScreen_Manager _startScreen_ManagerInstance; public static startScreen_Manager startScreen_ManagerInstance { get { if(_startScreen_ManagerInstance == null) { _startScreen_ManagerInstance = GameObject.FindObjectOfType(); DontDestroyOnLoad(_startScreen_ManagerInstance.gameObject); // Unity dont delete this object on level load. } return _startScreen_ManagerInstance; } } void Awake() { if(_startScreen_ManagerInstance == null) { _startScreen_ManagerInstance = this; DontDestroyOnLoad(this); } else { if(this != _startScreen_ManagerInstance ) { Destroy(this.gameObject); } } }

Viewing all articles
Browse latest Browse all 416

Latest Images

Trending Articles



Latest Images

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