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; }
/// <summary> /// Must NEVER be used in code (it only exists for editor purpose). /// </summary> public void Reset() { Height = 1.5f; MaxDistance = 1.5f; MinPitch = 0; MaxPitch = 0; LocalOffset = Vector3.zero; LocalRotation = Vector3.zero; Sensitivity = Vector2.one; RotationDamping = 0.3f; DistanceDamping = 0.8f; CollisionMask = 0; BlendOnEnter = null; }