// Token: 0x06004483 RID: 17539 RVA: 0x0016E22C File Offset: 0x0016C62C private void OnDestroy() { if (this.createdVRParentGO != null) { DestroyNotifier component = this.createdVRParentGO.GetComponent <DestroyNotifier>(); if (component != null) { component.OnDestroyedEvent -= this.OnPlayerEyesParentDestroyed; } UnityEngine.Object.Destroy(this.createdVRParentGO); } SceneManager.sceneLoaded -= this.OnSceneLoaded; }
// Token: 0x06004484 RID: 17540 RVA: 0x0016E290 File Offset: 0x0016C690 private void OnPlayerEyesParentDestroyed(DestroyNotifier destroyNotifier) { if (destroyNotifier.gameObject != this.createdVRParentGO) { Debug.LogWarning("Received OnPlayerEyesParentDestroyed from unknown gameObject " + destroyNotifier, destroyNotifier.gameObject); return; } this.createdVRParentGO = null; this.createdPlayerEyeCenterGO = null; this.createdPlayerLeftEyeGO = null; this.createdPlayerRightEyeGO = null; this.isInitialized = false; this.Initialize(); }
void OnDestroy() { if (createdVRParentGO != null) { DestroyNotifier destroyNotifier = createdVRParentGO.GetComponent <DestroyNotifier>(); if (destroyNotifier != null) { destroyNotifier.OnDestroyedEvent -= OnPlayerEyesParentDestroyed; } Destroy(createdVRParentGO); } if (isInitialized && eyeAndHeadAnimator != null) { eyeAndHeadAnimator.OnTargetDestroyed -= OnTargetDestroyed; eyeAndHeadAnimator.OnCannotGetTargetIntoView -= OnCannotGetTargetIntoView; eyeAndHeadAnimator.OnTargetOutOfSight -= OnTargetOutOfSight; eyeAndHeadAnimator.OnUpdate2Finished -= VeryLateUpdate; } }
// Token: 0x0600447B RID: 17531 RVA: 0x0016D7C0 File Offset: 0x0016BBC0 public void Initialize() { if (this.isInitialized) { return; } if (this.createdVRParentGO != null) { DestroyNotifier component = this.createdVRParentGO.GetComponent <DestroyNotifier>(); if (component != null) { component.OnDestroyedEvent -= this.OnPlayerEyesParentDestroyed; } UnityEngine.Object.Destroy(this.createdVRParentGO); this.createdVRParentGO = null; this.createdPlayerEyeCenterGO = null; this.createdPlayerLeftEyeGO = null; this.createdPlayerRightEyeGO = null; } this.eyeAndHeadAnimator = base.GetComponent <EyeAndHeadAnimator>(); this.eyeAndHeadAnimator.Initialize(true); this.playerEyeCenterXform = (this.playerLeftEyeXform = (this.playerRightEyeXform = null)); this.useNativeVRSupport = (this.useVR = (VRDevice.isPresent && VRSettings.enabled)); this.useNativeVRSupport = (this.useVR = false); GameObject gameObject = GameObject.Find("OVRCameraRig"); if (gameObject != null) { this.useVR = true; this.useNativeVRSupport = false; this.playerLeftEyeXform = Utils.FindChildInHierarchy(gameObject, "LeftEyeAnchor").transform; this.playerRightEyeXform = Utils.FindChildInHierarchy(gameObject, "RightEyeAnchor").transform; this.playerEyeCenterXform = Utils.FindChildInHierarchy(gameObject, "CenterEyeAnchor").transform; } else if (this.useNativeVRSupport) { if (Camera.main == null) { Debug.LogError("Main camera not found. Please set the main camera's tag to 'MainCamera'."); this.useVR = false; this.useNativeVRSupport = false; this.lookAtPlayerRatio = 0f; } else { this.createdPlayerEyeCenterGO = new GameObject("CreatedPlayerCenterVREye") { hideFlags = HideFlags.HideInHierarchy }; this.createdPlayerLeftEyeGO = new GameObject("CreatedPlayerLeftVREye") { hideFlags = HideFlags.HideInHierarchy }; this.createdPlayerRightEyeGO = new GameObject("CreatedPlayerRightVREye") { hideFlags = HideFlags.HideInHierarchy }; this.playerEyeCenterXform = this.createdPlayerEyeCenterGO.transform; this.playerLeftEyeXform = this.createdPlayerLeftEyeGO.transform; this.playerRightEyeXform = this.createdPlayerRightEyeGO.transform; Transform transform = Camera.main.transform; this.createdVRParentGO = new GameObject("PlayerEyesParent") { hideFlags = HideFlags.HideInHierarchy }; this.createdVRParentGO = new GameObject("PlayerEyesParent"); MonoBehaviour.print("created createdVRParentGO"); DestroyNotifier destroyNotifier = this.createdVRParentGO.AddComponent <DestroyNotifier>(); destroyNotifier.OnDestroyedEvent += this.OnPlayerEyesParentDestroyed; this.createdVRParentGO.transform.position = transform.position; this.createdVRParentGO.transform.rotation = transform.rotation; this.createdVRParentGO.transform.parent = transform.parent; this.createdPlayerEyeCenterGO.transform.parent = this.createdVRParentGO.transform; this.createdPlayerLeftEyeGO.transform.parent = this.createdVRParentGO.transform; this.createdPlayerRightEyeGO.transform.parent = this.createdVRParentGO.transform; this.UpdateNativeVRTransforms(); } } if (!this.useVR) { if (this.playerEyeCenter != null) { this.playerEyeCenterXform = this.playerEyeCenter; } else if (Camera.main != null) { this.playerEyeCenterXform = Camera.main.transform; } else { Debug.LogError("Main camera not found. Please set the main camera's tag to 'MainCamera' or set Player Eye Center."); this.lookAtPlayerRatio = 0f; } } this.UpdateThirdPersonPlayerEyeCenter(); this.LookAroundIdly(); this.nextChangePOITime = 0f; this.isInitialized = true; }
void OnCreatedXformDestroyed( DestroyNotifier destroyNotifer ) { Transform destroyedXform = destroyNotifer.GetComponent<Transform>(); for (int i=0; i<createdTargetXforms.Length; i++) if ( createdTargetXforms[i] == destroyedXform ) createdTargetXforms[i] = null; }
public void Initialize(bool lookAroundIdly = true) { if (isInitialized) { return; } if (createdVRParentGO != null) { DestroyNotifier destroyNotifier = createdVRParentGO.GetComponent <DestroyNotifier>(); if (destroyNotifier != null) { destroyNotifier.OnDestroyedEvent -= OnPlayerEyesParentDestroyed; } Destroy(createdVRParentGO); createdVRParentGO = null; createdPlayerEyeCenterGO = null; createdPlayerLeftEyeGO = null; createdPlayerRightEyeGO = null; } eyeAndHeadAnimator = GetComponent <EyeAndHeadAnimator>(); eyeAndHeadAnimator.Initialize(); eyeAndHeadAnimator.OnTargetDestroyed -= OnTargetDestroyed; eyeAndHeadAnimator.OnCannotGetTargetIntoView -= OnCannotGetTargetIntoView; eyeAndHeadAnimator.OnTargetOutOfSight -= OnTargetOutOfSight; eyeAndHeadAnimator.OnUpdate2Finished -= VeryLateUpdate; eyeAndHeadAnimator.OnTargetDestroyed += OnTargetDestroyed; eyeAndHeadAnimator.OnCannotGetTargetIntoView += OnCannotGetTargetIntoView; eyeAndHeadAnimator.OnTargetOutOfSight += OnTargetOutOfSight; eyeAndHeadAnimator.OnUpdate2Finished += VeryLateUpdate; playerEyeCenterXform = playerLeftEyeXform = playerRightEyeXform = null; //*** Player eyes: either user main camera or VR cameras { #if UNITY_2017_2_OR_NEWER useNativeVRSupport = useVR = XRDevice.isPresent && XRSettings.enabled; #else useNativeVRSupport = useVR = VRDevice.isPresent && VRSettings.enabled; #endif GameObject ovrRigGO = GameObject.Find("OVRCameraRig"); if (ovrRigGO != null) { useVR = true; useNativeVRSupport = false; playerLeftEyeXform = Utils.FindChildInHierarchy(ovrRigGO, "LeftEyeAnchor").transform; playerRightEyeXform = Utils.FindChildInHierarchy(ovrRigGO, "RightEyeAnchor").transform; playerEyeCenterXform = Utils.FindChildInHierarchy(ovrRigGO, "CenterEyeAnchor").transform; } else if (useNativeVRSupport) { if (FindPlayerCamera() == null) { Debug.LogWarning("Main camera not found. Please set the main camera's tag to 'MainCamera'."); useVR = false; useNativeVRSupport = false; lookAtPlayerRatio = 0; } else { mainCameraXform = FindPlayerCamera(); createdPlayerEyeCenterGO = new GameObject("CreatedPlayerCenterVREye") { hideFlags = HideFlags.HideInHierarchy }; createdPlayerLeftEyeGO = new GameObject("CreatedPlayerLeftVREye") { hideFlags = HideFlags.HideInHierarchy }; createdPlayerRightEyeGO = new GameObject("CreatedPlayerRightVREye") { hideFlags = HideFlags.HideInHierarchy }; playerEyeCenterXform = createdPlayerEyeCenterGO.transform; playerLeftEyeXform = createdPlayerLeftEyeGO.transform; playerRightEyeXform = createdPlayerRightEyeGO.transform; Transform playerXform = mainCameraXform; createdVRParentGO = new GameObject("PlayerEyesParent") { hideFlags = HideFlags.HideInHierarchy }; DontDestroyOnLoad(createdVRParentGO); DestroyNotifier destroyNotifier = createdVRParentGO.AddComponent <DestroyNotifier>(); destroyNotifier.OnDestroyedEvent += OnPlayerEyesParentDestroyed; createdVRParentGO.transform.position = playerXform.position; createdVRParentGO.transform.rotation = playerXform.rotation; createdVRParentGO.transform.parent = playerXform.parent; createdPlayerEyeCenterGO.transform.parent = createdVRParentGO.transform; createdPlayerLeftEyeGO.transform.parent = createdVRParentGO.transform; createdPlayerRightEyeGO.transform.parent = createdVRParentGO.transform; UpdateNativeVREyePositions(); } } if (false == useVR) { if (FindPlayerCamera() != null) { playerEyeCenterXform = FindPlayerCamera(); } else { Debug.LogWarning("Main camera not found. Please set the main camera's tag to 'MainCamera' or set Player Eye Center."); lookAtPlayerRatio = 0; } } } UpdatePlayerEyeTransformReferences(); isInitialized = true; if (lookAroundIdly) { LookAroundIdly(); } nextChangePOITime = 0; }