private void Awake() { if (singleton == null) { singleton = this; } else if (singleton != this) { Destroy(gameObject); } }
public RectTransform root; // the root object, the container for all the images public Character(string _name, bool enableOnStart = true) { CharacterManager cm = CharacterManager.instance; GameObject prefab = Resources.Load("Characters/Character[" + _name + "]") as GameObject; //to locate the ccharacters' files and as a GameObject rather than a normal object GameObject ob = GameObject.Instantiate(prefab, cm.characterPanel); //to respawn the characters into the scene. it is better than having invoke because you can control this easier root = ob.GetComponent <RectTransform>(); characterName = _name; renderers.singleLayerImage = ob.GetComponentInChildren <RawImage>(); if (isMultiLayerCharacter) { renderers.cuerpoRenderer = ob.transform.Find("cuerpoLayer").GetComponent <Image>(); //to get the expresions renderers.expresionRenderer = ob.transform.Find("expresionLayer").GetComponent <Image>(); } dialogue = SistemaDeDialogo.instance; //since this class is not a MonoBehavior, it is needed to store a reference point using this enabled = enableOnStart; }
public ELEMENTS elements; //we use the same name as the class, so we can call it over by using its constructor and also know that this store a point of reference in that clas void Awake() { instance = this; //this assure that this variable will be only use in this scene. I learned this keywork on Javascript }