IEnumerator TransitionToBehaviour(CameraBehaviour newBehaviour, bool awake = false) { if (ShowDebug) { Debug.Log("(Camera Master) Blending behaviors."); if (!newBehaviour.BlendOnEnter) { Debug.Log("No blend settings, using Default"); } } if (awake) { SetNewBehaviourValues(newBehaviour); yield break; } CameraBlendSettings blend = newBehaviour.BlendOnEnter ? newBehaviour.BlendOnEnter : CameraBlendSettings.Default; _isTransitingBehaviours = true; for (float f = 0; f < 1; f += Time.deltaTime / blend.Duration) { _height = Mathf.Lerp(_lastHeight, newBehaviour.Height, EasedLerp.EaseLerp(f, blend.Easing)); _maxDistance = Mathf.Lerp(_lastMaxDistance, newBehaviour.MaxDistance, EasedLerp.EaseLerp(f, blend.Easing)); _localOffset = Vector3.Lerp(_lastLocalOffset, newBehaviour.LocalOffset, EasedLerp.EaseLerp(f, blend.Easing)); _localRotation = Vector3.Lerp(_lastLocalRotation, newBehaviour.LocalRotation, EasedLerp.EaseLerp(f, blend.Easing)); yield return(null); } SetNewBehaviourValues(newBehaviour); _isTransitingBehaviours = false; }
IEnumerator MoveToPivot() { _isMovingToPivot = true; var initPos = m_Transform.position; var initRot = m_Transform.rotation; for (float f = 0; f < 1; f += Time.deltaTime / _moveToPivotDuration) { var lerp = EasedLerp.EaseLerp(f, 1); m_Transform.position = Vector3.Lerp(initPos, _lookAtPivot.position, lerp); m_Transform.rotation = Quaternion.Lerp(initRot, _lookAtPivot.rotation, lerp); yield return(null); } m_Transform.position = _lookAtPivot.position; m_Transform.rotation = _lookAtPivot.rotation; MovedToPivot?.Invoke(); }