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

Read variable from DontDestroyOnLoad GameObject C#

$
0
0
Hi I have a DontDestroyOnLoad GameObject that moves from Scene 1 to Scene 2. I also have a GameObject in Scene 2 that has to read an int from the DontDestroyOnLoad Object. Here is the Script DontDestroyOnLoad GameObject: public int myInteger; void Awake () { DontDestroyOnLoad(gameObject); } void Start(){ myInteger = = Random.Range(1, 4); } My normal Method to read the Integer from my other GameObject would be something like: public GameObject dontDestroyOnLoadObject; void Update () { if (dontDestroyOnLoadObject.GetComponent

Viewing all articles
Browse latest Browse all 416

Trending Articles



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