void Start() { // If there is no instance of this class, set it. if (Instance == null) { DontDestroyOnLoad (gameObject); // Don't destroy this object Instance = this; if (splashObj != null) { canvasObj = (GameObject)Instantiate (splashObj); canvasObj.transform.SetParent (transform); canvasObj.transform.position = Vector3.zero; splashCanvasGroup = canvasObj.GetComponent<CanvasGroup> (); canvasObj.GetComponent<Canvas> ().sortingOrder = 999; DontDestroyOnLoad (splashObj); } DontDestroyOnLoad (blackOverlay); blackOverlay.GetComponent<Canvas> ().sortingOrder = 998; Instance.StartCoroutine (LoadNextLevelFadeIn ()); } else { Debug.LogError ("There is already a SceneManager in the scene."); GameObject.Destroy (this); } }