private void SetCameraEnabled(bool state, bool force = false) { /* * Both AC and UFPS like to have their camera tagged as 'MainCamera', which causes conflict. * Therefore, this function ensures only one of these cameras is tagged as 'MainCamera' at any one time. * The same goes for the UFPS camera's AudioListener */ if (fpCamera != null && KickStarter.mainCamera != null) { if (state) { KickStarter.mainCamera.attachedCamera = null; } if (KickStarter.mainCamera.attachedCamera == null && !state && !force) { // Don't do anything if the MainCamera has nothing else to do fpCamera.tag = Tags.mainCamera; KickStarter.mainCamera.SetCameraTag(Tags.untagged); return; } // Need to disable camera, not gameobject, otherwise weapon cams will get wrong FOV foreach (Camera _camera in fpCamera.GetComponentsInChildren <Camera>()) { _camera.enabled = state; } if (_audioListener) { _audioListener.enabled = state; KickStarter.mainCamera.SetAudioState(!state); } if (state) { fpCamera.tag = Tags.mainCamera; KickStarter.mainCamera.SetCameraTag(Tags.untagged); KickStarter.mainCamera.Disable(); } else { fpCamera.tag = Tags.untagged; KickStarter.mainCamera.SetCameraTag(Tags.mainCamera); KickStarter.mainCamera.Enable(); } } }
/// <summary> /// /// </summary> public static Component GetFPCameraChildComponent(System.Type type, string name) { vp_FPCamera camera = GameObject.FindObjectOfType <vp_FPCamera>(); if (camera == null) { EditorUtility.DisplayDialog("Failed to find vp_FPCamera", "Make sure your scene has a gameobject with a vp_FPCamera component on it. ", "OK"); return(null); } foreach (Component c in camera.GetComponentsInChildren(type, true)) { if (c.name == name) { return(c); } } EditorUtility.DisplayDialog("Failed to find a matching " + type.Name, "Make sure the FPS camera object has a child gameobject with the exact name of \"" + name + "\", and that it has a " + type.Name + " component on it. ", "OK"); return(null); }
/// <summary> /// /// </summary> protected override void Awake() { base.Awake(); m_Inventory = Manager.Player.GetComponent<vp_Inventory>(); m_FPCamera = Manager.Player.GetComponentInChildren<vp_FPCamera>(); m_WeaponItems = m_FPCamera.GetComponentsInChildren<vp_ItemIdentifier>().ToList(); // sort the weapons alphabetically IComparer comparer = new WeaponComparer(); m_WeaponItems.Sort(comparer.Compare); }