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() { gameStateManagerRef = GameObject.FindGameObjectWithTag("MainObject").GetComponent<GameStateManager>(); inpManRef = gameStateManagerRef.GetInputManager(); worldCollisionRef = gameStateManagerRef.GetWorldCollision(); }