public void Start() { //Grab mainObject prefab to access managers effectively mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Notice, these are attached to the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); animationManagerRef = gameStateManagerRef.GetAnimationManager(); inputManagerRef = gameStateManagerRef.GetInputManager(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); // This script is attached to the player, so we use 'gameObject' here controllerRef = gameObject.GetComponent<TWCharacterController>(); paperObject = GameObject.FindGameObjectWithTag("background"); }
// Use this for initialization void Start() { GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureGameScriptsAdded(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); }
// Use this for initialization void Start() { GameObject mainObject = GameObject.FindGameObjectsWithTag("MainObject")[0]; if (GameObject.FindGameObjectsWithTag("MainObject").Length > 1) { GameObject[] mainObjectList = GameObject.FindGameObjectsWithTag("MainObject"); for (int i = 0; i < mainObjectList.Length; ++i) { if (mainObjectList[i].GetComponent<GameStateManager>().objectSaved) mainObject = mainObjectList[i]; } } // Ensures all necessary scripts are added for the MainObject gameStateManagerRef = mainObject.GetComponent<GameStateManager>(); gameStateManagerRef.EnsureGameScriptsAdded(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); playerRef = GameObject.FindGameObjectWithTag("Player").GetComponent<TWCharacterController>(); //Init local reference - J.C. TearManagerLocalRef = GameObject.FindGameObjectWithTag("TearManager").GetComponent<TearManager>(); }
// Use this for initialization void Start() { gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); inpManRef = gameStateManagerRef.GetInputManager(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); }