void Awake() { parentCanvas = this.transform.parent.gameObject; DontDestroyOnLoad(parentCanvas); if (ourFaderReference == null) { ourFaderReference = this; } else if (ourFaderReference != this) { Destroy(gameObject); } faderRawImage = this.GetComponent <RawImage>(); }
// Use this for pre-initialization void Awake() { //Assign the Parent GameObject to the parentCanvas var. parentCanvas = this.transform.parent.gameObject; //make sure that it persists thru scene load using DontDestroyOnLoad DontDestroyOnLoad(parentCanvas); //Make this instance the if (ourFaderReference == null) { ourFaderReference = this; } else if (ourFaderReference != this) { Destroy(gameObject); } //the RawImage this script is attached to is assigned to the faderRawImage var faderRawImage = this.GetComponent <RawImage>(); }