Exemple #1
0
        /// <summary>
        /// Gets the scene controller (returns null on fail)
        /// </summary>
        public static BaseSceneController TryGetSceneController()
        {
            //TODO refactor this to use CoreUtils.GetWorldRoot

            GameObject go = GameObject.FindGameObjectWithTag("GameController");

            if (go != null)
            {
                BaseSceneController bsc = go.GetComponent <BaseSceneController>();

                if (bsc != null)
                {
                    return(bsc);
                }
            }

            //couldn't find it, try grabbing WorldRoot
            go = GameObject.Find("WorldRoot");
            if (go != null)
            {
                BaseSceneController bsc = go.GetComponent <BaseSceneController>();

                if (bsc != null)
                {
                    return(bsc);
                }
            }

            return(null);
        }
Exemple #2
0
        /// <summary>
        /// Gets the scene controller (throws on fail)
        /// </summary>
        public static BaseSceneController GetSceneController()
        {
            BaseSceneController bsc = TryGetSceneController();

            if (bsc != null)
            {
                return(bsc);
            }

            //still couldn't find it, throw an error
            Debug.LogError("Couldn't find SceneController");

            throw new NullReferenceException(); //not having a scene controller is fatal
        }
Exemple #3
0
        /// <summary>
        /// Gets the scene controller (returns null on fail)
        /// </summary>
        public static BaseSceneController TryGetSceneController()
        {
            if (BaseSceneController.Current != null)
            {
                return(BaseSceneController.Current);
            }

            // try grabbing WorldRoot
            Transform t = CoreUtils.GetWorldRoot();

            if (t != null)
            {
                BaseSceneController bsc = t.gameObject.GetComponent <BaseSceneController>();

                if (bsc != null)
                {
                    return(bsc);
                }
            }

            return(null);
        }