/// <summary> /// Sets up the room to work with Photon PUN. /// </summary> private void SetupScene() { // Create the pun components if they doesn't already exists. GameObject punGameObject; StateSystem.PunStateManager stateManager; if ((stateManager = GameObject.FindObjectOfType <StateSystem.PunStateManager>()) == null) { punGameObject = new GameObject("PunGame"); } else { punGameObject = stateManager.gameObject; } // Add the Singletons. InspectorUtility.AddComponent <Game.PunObjectPool>(punGameObject); InspectorUtility.AddComponent <Game.RuntimePickups>(punGameObject); InspectorUtility.AddComponent <Game.SingleCharacterSpawnManager>(punGameObject); var itemTypeTracker = InspectorUtility.AddComponent <Game.ItemTypeTracker>(punGameObject); if (itemTypeTracker.ItemCollection == null) { itemTypeTracker.ItemCollection = ManagerUtility.FindItemCollection(m_MainManagerWindow); } InspectorUtility.AddComponent <StateSystem.PunStateManager>(punGameObject); // The camera controller should not initialize the character on awake. var cameraController = GameObject.FindObjectOfType <Camera.CameraController>(); if (cameraController != null) { cameraController.InitCharacterOnAwake = false; } // The SceneObjectIdentifier should be added to every collider within the scene. if (m_AddSceneIdentifiers) { var sceneObjectID = 1; var colliders = GameObject.FindObjectsOfType <Collider>(); for (int i = 0; i < colliders.Length; ++i) { if (colliders[i].isTrigger || colliders[i].gameObject.scene.rootCount == 0 || colliders[i].GetComponent <PhotonView>() != null) { continue; } // The ID should be unique within the scene. var sceneObjectIdentifier = InspectorUtility.AddComponent <Objects.SceneObjectIdentifier>(colliders[i].gameObject); sceneObjectIdentifier.ID = sceneObjectID; sceneObjectID++; InspectorUtility.SetDirty(sceneObjectIdentifier); } } }
/// <summary> /// Finds the Item Collection. /// </summary> protected override void OnEnable() { base.OnEnable(); m_ItemCollection = ManagerUtility.FindItemCollection(this); }