/// <summary> /// Called when the component is enabled. This is also called after awake. So, /// we need to ensure we're not doubling up on the assignment. /// </summary> protected void OnEnable() { if (_Anchor != null) { ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject); if (lController != null) { if (lController.OnControllerPostLateUpdate != null) { lController.OnControllerPostLateUpdate -= OnControllerLateUpdate; } lController.OnControllerPostLateUpdate += OnControllerLateUpdate; } else { IBaseCameraAnchor lAnchor = _Anchor.GetComponent <IBaseCameraAnchor>(); if (lAnchor != null) { if (lAnchor.OnAnchorPostLateUpdate != null) { lAnchor.OnAnchorPostLateUpdate -= OnControllerLateUpdate; } lAnchor.OnAnchorPostLateUpdate += OnControllerLateUpdate; } } } }
/// <summary> /// Use this for initialization /// </summary> protected override void Awake() { base.Awake(); if (_Anchor != null && this.enabled) { ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject); if (lController == null) { IBaseCameraAnchor lAnchor = _Anchor.GetComponent <IBaseCameraAnchor>(); if (lAnchor != null) { IsInternalUpdateEnabled = false; IsFixedUpdateEnabled = false; lAnchor.OnAnchorPostLateUpdate += OnControllerLateUpdate; } else { IsInternalUpdateEnabled = true; } } else { IsInternalUpdateEnabled = false; IsFixedUpdateEnabled = false; lController.OnControllerPostLateUpdate += OnControllerLateUpdate; } } }
/// <summary> /// Use this for initialization /// </summary> protected override void Awake() { base.Awake(); if (_Anchor != null && this.enabled) { ICharacterController lController = InterfaceHelper.GetComponent <ICharacterController>(_Anchor.gameObject); if (lController == null) { IBaseCameraAnchor lAnchor = _Anchor.GetComponent <IBaseCameraAnchor>(); if (lAnchor != null) { IsInternalUpdateEnabled = false; IsFixedUpdateEnabled = false; lAnchor.OnAnchorPostLateUpdate += OnControllerLateUpdate; } else { IsInternalUpdateEnabled = true; } } else { IsInternalUpdateEnabled = false; IsFixedUpdateEnabled = false; lController.OnControllerPostLateUpdate += OnControllerLateUpdate; } mTilt = QuaternionExt.FromToRotation(_Transform.up, _Anchor.up); mToCameraDirection = _Transform.position - _Anchor.position; mToCameraDirection.y = 0f; mToCameraDirection.Normalize(); if (mToCameraDirection.sqrMagnitude == 0f) { mToCameraDirection = -_Anchor.forward; } } // Object that will provide access to the keyboard, mouse, etc if (_InputSourceOwner != null) { mInputSource = InterfaceHelper.GetComponent <IInputSource>(_InputSourceOwner); } // Default the speed we'll use to rotate mDegreesPer60FPSTick = _RotationSpeed / 60f; }