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

Objects of global singleton aren't accessible

$
0
0
I am trying to create some kind of global class storing player data which could be accessible in the whole project. I created simple singleton using this code: void Awake () { if(Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else Destroy(this); } Unfortunately only simple variables (like int, string) are acessible. Objects in other scenes are null. What can I do to make them alive just like their simple brothers? @Edit: More code: using UnityEngine; using System.Collections; public class PlayerInfo : MonoBehaviour { public static PlayerInfo Instance; public string Name; //string static Password; public int Money; public byte Flat; public byte Gender; public long CreateDate; public Skills Skills; void Awake () { if(Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else Destroy(this); } } [Serializable] public class Skills{ public byte dexterity; public byte vocabulary; // talking skillz // add more }

Viewing all articles
Browse latest Browse all 416

Trending Articles



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