Added Feel plugin
This commit is contained in:
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76b756cf8480fcd4bb9db669233c29c5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,166 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
[System.Serializable]
|
||||
[AddComponentMenu("")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[FeedbackPath("Camera/Cinemachine Impulse")]
|
||||
#endif
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
|
||||
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse event. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
|
||||
public class MMF_CinemachineImpulse : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
|
||||
public override bool HasCustomInspectors => true;
|
||||
public override bool HasAutomaticShakerSetup => true;
|
||||
#endif
|
||||
public override bool HasRandomness => true;
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[MMFInspectorGroup("Cinemachine Impulse", true, 28)]
|
||||
/// the impulse definition to broadcast
|
||||
[Tooltip("the impulse definition to broadcast")]
|
||||
public CinemachineImpulseDefinition m_ImpulseDefinition = new CinemachineImpulseDefinition();
|
||||
/// the velocity to apply to the impulse shake
|
||||
[Tooltip("the velocity to apply to the impulse shake")]
|
||||
public Vector3 Velocity;
|
||||
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
|
||||
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
|
||||
public bool ClearImpulseOnStop = false;
|
||||
#endif
|
||||
|
||||
[Header("Gizmos")]
|
||||
/// whether or not to draw gizmos to showcase the various distance properties of this feedback, when applicable. Dissipation distance in blue, impact radius in yellow.
|
||||
[Tooltip("whether or not to draw gizmos to showcase the various distance properties of this feedback, when applicable. Dissipation distance in blue, impact radius in yellow.")]
|
||||
public bool DrawGizmos = false;
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
/// the duration of this feedback is the duration of the impulse
|
||||
public override float FeedbackDuration { get { return m_ImpulseDefinition != null ? m_ImpulseDefinition.m_TimeEnvelope.Duration : 0f; } }
|
||||
#elif MM_CINEMACHINE3
|
||||
/// the duration of this feedback is the duration of the impulse
|
||||
public override float FeedbackDuration { get { return m_ImpulseDefinition != null ? m_ImpulseDefinition.TimeEnvelope.Duration : 0f; } }
|
||||
#endif
|
||||
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
CinemachineImpulseManager.Instance.IgnoreTimeScale = !InScaledTimescaleMode;
|
||||
float intensityMultiplier = ComputeIntensity(feedbacksIntensity, position);
|
||||
m_ImpulseDefinition.CreateEvent(position, Velocity * intensityMultiplier);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the animation if needed
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.CustomStopFeedback(position, feedbacksIntensity);
|
||||
CinemachineImpulseManager.Instance.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When adding the feedback we initialize its cinemachine impulse definition
|
||||
/// </summary>
|
||||
public override void OnAddFeedback()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
// sets the feedback properties
|
||||
if (this.m_ImpulseDefinition == null)
|
||||
{
|
||||
this.m_ImpulseDefinition = new CinemachineImpulseDefinition();
|
||||
}
|
||||
this.m_ImpulseDefinition.m_RawSignal = Resources.Load<NoiseSettings>("MM_6D_Shake");
|
||||
this.Velocity = new Vector3(5f, 5f, 5f);
|
||||
#elif MM_CINEMACHINE3
|
||||
// sets the feedback properties
|
||||
if (this.m_ImpulseDefinition == null)
|
||||
{
|
||||
this.m_ImpulseDefinition = new CinemachineImpulseDefinition();
|
||||
}
|
||||
this.m_ImpulseDefinition.RawSignal = Resources.Load<NoiseSettings>("MM_6D_Shake");
|
||||
this.Velocity = new Vector3(5f, 5f, 5f);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws dissipation distance and impact distance gizmos if necessary
|
||||
/// </summary>
|
||||
public override void OnDrawGizmosSelectedHandler()
|
||||
{
|
||||
if (!DrawGizmos)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if MM_CINEMACHINE
|
||||
{
|
||||
if ( (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Dissipating)
|
||||
|| (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Propagating)
|
||||
|| (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy) )
|
||||
{
|
||||
Gizmos.color = MMColors.Aqua;
|
||||
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.m_DissipationDistance);
|
||||
}
|
||||
if (this.m_ImpulseDefinition.m_ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy)
|
||||
{
|
||||
Gizmos.color = MMColors.ReunoYellow;
|
||||
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.m_ImpactRadius);
|
||||
}
|
||||
}
|
||||
#elif MM_CINEMACHINE3
|
||||
if (this.m_ImpulseDefinition != null)
|
||||
{
|
||||
if ( (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Dissipating)
|
||||
|| (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Propagating)
|
||||
|| (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy) )
|
||||
{
|
||||
Gizmos.color = MMColors.Aqua;
|
||||
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.DissipationDistance);
|
||||
}
|
||||
if (this.m_ImpulseDefinition.ImpulseType == CinemachineImpulseDefinition.ImpulseTypes.Legacy)
|
||||
{
|
||||
Gizmos.color = MMColors.ReunoYellow;
|
||||
Gizmos.DrawWireSphere(Owner.transform.position, this.m_ImpulseDefinition.ImpactRadius);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Automatically adds a Cinemachine Impulse Listener to the camera
|
||||
/// </summary>
|
||||
public override void AutomaticShakerSetup()
|
||||
{
|
||||
MMCinemachineHelpers.AutomaticCinemachineShakersSetup(Owner, "CinemachineImpulse");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2ee48f409bf2e3e4baf85ca77d2ca0af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks/MMF_CinemachineImpulse.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,39 @@
|
||||
using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
[AddComponentMenu("")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Camera/Cinemachine Impulse Clear")]
|
||||
#endif
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
|
||||
[FeedbackHelp("This feedback lets you trigger a Cinemachine Impulse clear, stopping instantly any impulse that may be playing.")]
|
||||
public class MMF_CinemachineImpulseClear : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
|
||||
#endif
|
||||
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
CinemachineImpulseManager.Instance.Clear();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b2362762ee575ad4ab16bb938247878b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks/MMF_CinemachineImpulseClear.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,99 @@
|
||||
using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
[System.Serializable]
|
||||
[AddComponentMenu("")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[FeedbackPath("Camera/Cinemachine Impulse Source")]
|
||||
#endif
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
|
||||
[FeedbackHelp("This feedback lets you generate an impulse on a Cinemachine Impulse source. You'll need a Cinemachine Impulse Listener on your camera for this to work.")]
|
||||
public class MMF_CinemachineImpulseSource : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
public override bool EvaluateRequiresSetup() { return (ImpulseSource == null); }
|
||||
public override string RequiredTargetText { get { return ImpulseSource != null ? ImpulseSource.name : ""; } }
|
||||
#endif
|
||||
public override string RequiresSetupText { get { return "This feedback requires that an ImpulseSource be set to be able to work properly. You can set one below."; } }
|
||||
#endif
|
||||
|
||||
|
||||
[MMFInspectorGroup("Cinemachine Impulse Source", true, 28)]
|
||||
|
||||
/// the velocity to apply to the impulse shake
|
||||
[Tooltip("the velocity to apply to the impulse shake")]
|
||||
public Vector3 Velocity = new Vector3(1f,1f,1f);
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
/// the impulse definition to broadcast
|
||||
[Tooltip("the impulse definition to broadcast")]
|
||||
public CinemachineImpulseSource ImpulseSource;
|
||||
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
protected override void AutomateTargetAcquisition() => ImpulseSource = FindAutomatedTarget<CinemachineImpulseSource>();
|
||||
#endif
|
||||
/// whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback
|
||||
[Tooltip("whether or not to clear impulses (stopping camera shakes) when the Stop method is called on that feedback")]
|
||||
public bool ClearImpulseOnStop = false;
|
||||
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
if (ImpulseSource != null)
|
||||
{
|
||||
ImpulseSource.GenerateImpulse(Velocity);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the animation if needed
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomStopFeedback(Vector3 position, float feedbacksIntensity = 1)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized || !ClearImpulseOnStop)
|
||||
{
|
||||
return;
|
||||
}
|
||||
base.CustomStopFeedback(position, feedbacksIntensity);
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
CinemachineImpulseManager.Instance.Clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we put our object back at its initial position
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
CinemachineImpulseManager.Instance.Clear();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0f6892e7c981ffa45ad8e24c33bdac4e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks/MMF_CinemachineImpulseSource.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,151 @@
|
||||
using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using UnityEngine.Scripting.APIUpdating;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// This feedback will let you change the priorities of your cameras.
|
||||
/// It requires a bit of setup : adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them.
|
||||
/// Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations.
|
||||
/// Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!
|
||||
/// </summary>
|
||||
[AddComponentMenu("")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[System.Serializable]
|
||||
[FeedbackPath("Camera/Cinemachine Transition")]
|
||||
#endif
|
||||
[MovedFrom(false, null, "MoreMountains.Feedbacks.Cinemachine")]
|
||||
[FeedbackHelp("This feedback will let you change the priorities of your cameras. It requires a bit of setup : " +
|
||||
"adding a MMCinemachinePriorityListener to your different cameras, with unique Channel values on them. " +
|
||||
"Optionally, you can add a MMCinemachinePriorityBrainListener on your Cinemachine Brain to handle different transition types and durations. " +
|
||||
"Then all you have to do is pick a channel and a new priority on your feedback, and play it. Magic transition!")]
|
||||
public class MMF_CinemachineTransition : MMF_Feedback
|
||||
{
|
||||
/// a static bool used to disable all feedbacks of this type at once
|
||||
public static bool FeedbackTypeAuthorized = true;
|
||||
public enum Modes { Event, Binding }
|
||||
|
||||
/// sets the inspector color for this feedback
|
||||
#if UNITY_EDITOR
|
||||
public override Color FeedbackColor { get { return MMFeedbacksInspectorColors.CameraColor; } }
|
||||
public override string RequiredTargetText => RequiredChannelText;
|
||||
#endif
|
||||
#if MM_CINEMACHINE
|
||||
/// the duration of this feedback is the duration of the shake
|
||||
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.m_Time); } set { BlendDefintion.m_Time = value; } }
|
||||
#elif MM_CINEMACHINE3
|
||||
public override float FeedbackDuration { get { return ApplyTimeMultiplier(BlendDefintion.Time); } set { BlendDefintion.Time = value; } }
|
||||
#endif
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
public override bool HasAutomatedTargetAcquisition => true;
|
||||
#endif
|
||||
#if MM_CINEMACHINE
|
||||
protected override void AutomateTargetAcquisition() => TargetVirtualCamera = FindAutomatedTarget<CinemachineVirtualCamera>();
|
||||
#elif MM_CINEMACHINE3
|
||||
protected override void AutomateTargetAcquisition() => TargetCinemachineCamera = FindAutomatedTarget<CinemachineCamera>();
|
||||
#endif
|
||||
public override bool HasChannel => true;
|
||||
|
||||
[MMFInspectorGroup("Cinemachine Transition", true, 52)]
|
||||
/// the selected mode (either via event, or via direct binding of a specific camera)
|
||||
[Tooltip("the selected mode (either via event, or via direct binding of a specific camera)")]
|
||||
public Modes Mode = Modes.Event;
|
||||
#if MM_CINEMACHINE
|
||||
/// the virtual camera to target
|
||||
[Tooltip("the virtual camera to target")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.Binding)]
|
||||
public CinemachineVirtualCamera TargetVirtualCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
/// the Cinemachine camera to target
|
||||
[Tooltip("the Cinemachine camera to target")]
|
||||
[MMFEnumCondition("Mode", (int)Modes.Binding)]
|
||||
public CinemachineCamera TargetCinemachineCamera;
|
||||
#endif
|
||||
/// whether or not to reset the target's values after shake
|
||||
[Tooltip("whether or not to reset the target's values after shake")]
|
||||
public bool ResetValuesAfterTransition = true;
|
||||
|
||||
[Header("Priority")]
|
||||
/// the new priority to apply to all virtual cameras on the specified channel
|
||||
[Tooltip("the new priority to apply to all virtual cameras on the specified channel")]
|
||||
public int NewPriority = 10;
|
||||
/// whether or not to force all virtual cameras on other channels to reset their priority to zero
|
||||
[Tooltip("whether or not to force all virtual cameras on other channels to reset their priority to zero")]
|
||||
public bool ForceMaxPriority = true;
|
||||
/// whether or not to apply a new blend
|
||||
[Tooltip("whether or not to apply a new blend")]
|
||||
public bool ForceTransition = false;
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
/// the new blend definition to apply
|
||||
[Tooltip("the new blend definition to apply")]
|
||||
[MMFCondition("ForceTransition", true)]
|
||||
public CinemachineBlendDefinition BlendDefintion;
|
||||
|
||||
protected CinemachineBlendDefinition _tempBlend;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Triggers a priority change on listening virtual cameras
|
||||
/// </summary>
|
||||
/// <param name="position"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
protected override void CustomPlayFeedback(Vector3 position, float feedbacksIntensity = 1.0f)
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
_tempBlend = BlendDefintion;
|
||||
#endif
|
||||
#if MM_CINEMACHINE
|
||||
_tempBlend.m_Time = FeedbackDuration;
|
||||
#elif MM_CINEMACHINE3
|
||||
_tempBlend.Time = FeedbackDuration;
|
||||
#endif
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
if (Mode == Modes.Event)
|
||||
{
|
||||
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, NewPriority, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode);
|
||||
SetPriority(NewPriority);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
protected virtual void SetPriority(int newPriority)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
TargetVirtualCamera.Priority = newPriority;
|
||||
#elif MM_CINEMACHINE3
|
||||
PrioritySettings prioritySettings = TargetCinemachineCamera.Priority;
|
||||
prioritySettings.Value = newPriority;
|
||||
TargetCinemachineCamera.Priority = prioritySettings;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On restore, we restore our initial state
|
||||
/// </summary>
|
||||
protected override void CustomRestoreInitialValues()
|
||||
{
|
||||
if (!Active || !FeedbackTypeAuthorized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
MMCinemachinePriorityEvent.Trigger(ChannelData, ForceMaxPriority, 0, ForceTransition, _tempBlend, ResetValuesAfterTransition, ComputedTimescaleMode, true);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2838524600839f84591c1d8a457b2176
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Feedbacks/MMF_CinemachineTransition.cs
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Helpers.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Helpers.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 012099a7c01491d498f5f9098f2c1537
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,99 @@
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
public class MMCinemachineHelpers : MonoBehaviour
|
||||
{
|
||||
public static GameObject AutomaticCinemachineShakersSetup(MMF_Player owner, string feedbackName)
|
||||
{
|
||||
GameObject virtualCameraGo = null;
|
||||
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
bool newVcam = false;
|
||||
string additions = owner.name + " "+feedbackName+" feedback automatic shaker setup : ";
|
||||
#endif
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
//looks for a Cinemachine Brain in the scene
|
||||
CinemachineBrain cinemachineBrain = (CinemachineBrain)Object.FindAnyObjectByType(typeof(CinemachineBrain));
|
||||
if (cinemachineBrain == null)
|
||||
{
|
||||
cinemachineBrain = Camera.main.gameObject.AddComponent<CinemachineBrain>();
|
||||
additions += "Added a Cinemachine Brain to the scene. ";
|
||||
}
|
||||
|
||||
// looks for a vcam in the scene
|
||||
CinemachineVirtualCamera virtualCamera = (CinemachineVirtualCamera)Object.FindAnyObjectByType(typeof(CinemachineVirtualCamera));
|
||||
if (virtualCamera == null)
|
||||
{
|
||||
GameObject newVirtualCamera = new GameObject("CinemachineVirtualCamera");
|
||||
if (Camera.main != null)
|
||||
{
|
||||
newVirtualCamera.transform.position = Camera.main.transform.position;
|
||||
}
|
||||
virtualCamera = newVirtualCamera.AddComponent<CinemachineVirtualCamera>();
|
||||
additions += "Added a Cinemachine Virtual Camera to the scene. ";
|
||||
newVcam = true;
|
||||
}
|
||||
virtualCameraGo = virtualCamera.gameObject;
|
||||
CinemachineImpulseListener impulseListener = virtualCamera.GetComponent<CinemachineImpulseListener>();
|
||||
if (impulseListener == null)
|
||||
{
|
||||
impulseListener = virtualCamera.gameObject.AddComponent<CinemachineImpulseListener>();
|
||||
additions += "Added an impulse listener. ";
|
||||
}
|
||||
#elif MM_CINEMACHINE3
|
||||
//looks for a Cinemachine Brain in the scene
|
||||
CinemachineBrain cinemachineBrain = (CinemachineBrain)Object.FindAnyObjectByType(typeof(CinemachineBrain));
|
||||
if (cinemachineBrain == null)
|
||||
{
|
||||
cinemachineBrain = Camera.main.gameObject.AddComponent<CinemachineBrain>();
|
||||
additions += "Added a Cinemachine Brain to the scene. ";
|
||||
}
|
||||
// looks for a vcam in the scene
|
||||
CinemachineCamera virtualCamera = (CinemachineCamera)Object.FindAnyObjectByType(typeof(CinemachineCamera));
|
||||
if (virtualCamera == null)
|
||||
{
|
||||
GameObject newVirtualCamera = new GameObject("CinemachineCamera");
|
||||
if (Camera.main != null)
|
||||
{
|
||||
newVirtualCamera.transform.position = Camera.main.transform.position;
|
||||
}
|
||||
virtualCamera = newVirtualCamera.AddComponent<CinemachineCamera>();
|
||||
additions += "Added a Cinemachine Camera to the scene. ";
|
||||
newVcam = true;
|
||||
}
|
||||
virtualCameraGo = virtualCamera.gameObject;
|
||||
CinemachineImpulseListener impulseListener = virtualCamera.GetComponent<CinemachineImpulseListener>();
|
||||
if (impulseListener == null)
|
||||
{
|
||||
impulseListener = virtualCamera.gameObject.AddComponent<CinemachineImpulseListener>();
|
||||
additions += "Added an impulse listener. ";
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
if (newVcam)
|
||||
{
|
||||
virtualCameraGo.MMGetOrAddComponent<MMCinemachineCameraShaker>();
|
||||
virtualCameraGo.MMGetOrAddComponent<MMCinemachineZoom>();
|
||||
virtualCameraGo.MMGetOrAddComponent<MMCinemachinePriorityListener>();
|
||||
virtualCameraGo.MMGetOrAddComponent<MMCinemachineClippingPlanesShaker>();
|
||||
virtualCameraGo.MMGetOrAddComponent<MMCinemachineFieldOfViewShaker>();
|
||||
additions += "Added camera shaker, zoom, priority listener, clipping planes shaker and field of view shaker to the Cinemachine Camera. ";
|
||||
}
|
||||
|
||||
MMDebug.DebugLogInfo( additions + "You're all set.");
|
||||
#endif
|
||||
return virtualCameraGo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53907edcd2e7d344c8517b4e1da9e75f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Helpers/MMCinemachineHelpers.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"reference": "GUID:4a1cb1490dc4df8409b2580d6b44e75e"
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
fileFormatVersion: 2
|
||||
guid: afb2be2d186835148b46d3b0c4ae900d
|
||||
AssemblyDefinitionReferenceImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/MoreMountains.Feedbacks.Cinemachine.asmref
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Resources.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Resources.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f6a830756be1b440bf6d073f91619d7
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,87 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!114 &11400000
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: b7f59e54f2bfd184b9dd451a678d089b, type: 3}
|
||||
m_Name: MM_6D_Shake
|
||||
m_EditorClassIdentifier:
|
||||
PositionNoise:
|
||||
- X:
|
||||
Frequency: 3.2
|
||||
Amplitude: 0.011
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 1.9
|
||||
Amplitude: 0.059
|
||||
Constant: 1
|
||||
Z:
|
||||
Frequency: 3.33
|
||||
Amplitude: 0.021
|
||||
Constant: 1
|
||||
- X:
|
||||
Frequency: 7.7
|
||||
Amplitude: 0.009
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 9.1
|
||||
Amplitude: 0.04
|
||||
Constant: 0
|
||||
Z:
|
||||
Frequency: 9.22
|
||||
Amplitude: 0.009
|
||||
Constant: 1
|
||||
- X:
|
||||
Frequency: 51.51
|
||||
Amplitude: 0.002
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 55.54
|
||||
Amplitude: 0.05
|
||||
Constant: 1
|
||||
Z:
|
||||
Frequency: 58.55
|
||||
Amplitude: 0.017
|
||||
Constant: 1
|
||||
OrientationNoise:
|
||||
- X:
|
||||
Frequency: 5.83
|
||||
Amplitude: 0.09
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 1.8
|
||||
Amplitude: 0.059
|
||||
Constant: 1
|
||||
Z:
|
||||
Frequency: 2.38
|
||||
Amplitude: 0.017
|
||||
Constant: 1
|
||||
- X:
|
||||
Frequency: 9.17
|
||||
Amplitude: 0.14
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 11.35
|
||||
Amplitude: 0.041
|
||||
Constant: 1
|
||||
Z:
|
||||
Frequency: 10.52
|
||||
Amplitude: 0.009
|
||||
Constant: 1
|
||||
- X:
|
||||
Frequency: 57.17
|
||||
Amplitude: 0.15
|
||||
Constant: 1
|
||||
Y:
|
||||
Frequency: 54.17
|
||||
Amplitude: 0.048
|
||||
Constant: 1
|
||||
Z:
|
||||
Frequency: 63.76
|
||||
Amplitude: 0.016
|
||||
Constant: 1
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcf6524ce6451f34cb7106d0c00da9a5
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Resources/MM_6D_Shake.asset
|
||||
uploadId: 830868
|
||||
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers.meta
vendored
Normal file
8
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers.meta
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 22217fa6cb1ecde4ba6e2ccdeff4ba33
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,233 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this component to your Cinemachine Virtual Camera to have it shake when calling its ShakeCamera methods.
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Camera Shaker")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(CinemachineVirtualCamera))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineCameraShaker : MonoBehaviour
|
||||
{
|
||||
[Header("Settings")]
|
||||
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
|
||||
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
|
||||
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
|
||||
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
|
||||
public MMChannelModes ChannelMode = MMChannelModes.Int;
|
||||
/// the channel to listen to - has to match the one on the feedback
|
||||
[Tooltip("the channel to listen to - has to match the one on the feedback")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
|
||||
public int Channel = 0;
|
||||
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
|
||||
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
|
||||
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
|
||||
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
|
||||
public MMChannel MMChannelDefinition = null;
|
||||
/// The default amplitude that will be applied to your shakes if you don't specify one
|
||||
[Tooltip("The default amplitude that will be applied to your shakes if you don't specify one")]
|
||||
public float DefaultShakeAmplitude = .5f;
|
||||
/// The default frequency that will be applied to your shakes if you don't specify one
|
||||
[Tooltip("The default frequency that will be applied to your shakes if you don't specify one")]
|
||||
public float DefaultShakeFrequency = 10f;
|
||||
/// the amplitude of the camera's noise when it's idle
|
||||
[Tooltip("the amplitude of the camera's noise when it's idle")]
|
||||
[MMFReadOnly]
|
||||
public float IdleAmplitude;
|
||||
/// the frequency of the camera's noise when it's idle
|
||||
[Tooltip("the frequency of the camera's noise when it's idle")]
|
||||
[MMFReadOnly]
|
||||
public float IdleFrequency = 1f;
|
||||
/// the speed at which to interpolate the shake
|
||||
[Tooltip("the speed at which to interpolate the shake")]
|
||||
public float LerpSpeed = 5f;
|
||||
|
||||
[Header("Test")]
|
||||
/// a duration (in seconds) to apply when testing this shake via the TestShake button
|
||||
[Tooltip("a duration (in seconds) to apply when testing this shake via the TestShake button")]
|
||||
public float TestDuration = 0.3f;
|
||||
/// the amplitude to apply when testing this shake via the TestShake button
|
||||
[Tooltip("the amplitude to apply when testing this shake via the TestShake button")]
|
||||
public float TestAmplitude = 2f;
|
||||
/// the frequency to apply when testing this shake via the TestShake button
|
||||
[Tooltip("the frequency to apply when testing this shake via the TestShake button")]
|
||||
public float TestFrequency = 20f;
|
||||
|
||||
[MMFInspectorButton("TestShake")]
|
||||
public bool TestShakeButton;
|
||||
|
||||
public virtual float GetTime() { return (_timescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
|
||||
public virtual float GetDeltaTime() { return (_timescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
|
||||
|
||||
protected TimescaleModes _timescaleMode;
|
||||
protected Vector3 _initialPosition;
|
||||
protected Quaternion _initialRotation;
|
||||
#if MM_CINEMACHINE
|
||||
protected Cinemachine.CinemachineBasicMultiChannelPerlin _perlin;
|
||||
protected Cinemachine.CinemachineVirtualCamera _virtualCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineBasicMultiChannelPerlin _perlin;
|
||||
protected CinemachineCamera _virtualCamera;
|
||||
#endif
|
||||
protected float _targetAmplitude;
|
||||
protected float _targetFrequency;
|
||||
private Coroutine _shakeCoroutine;
|
||||
|
||||
/// <summary>
|
||||
/// On awake we grab our components
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_virtualCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
_perlin = _virtualCamera.GetCinemachineComponent<Cinemachine.CinemachineBasicMultiChannelPerlin>();
|
||||
#elif MM_CINEMACHINE3
|
||||
_virtualCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
_perlin = _virtualCamera.GetCinemachineComponent(CinemachineCore.Stage.Noise) as CinemachineBasicMultiChannelPerlin;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Start we reset our camera to apply our base amplitude and frequency
|
||||
/// </summary>
|
||||
protected virtual void Start()
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
if (_perlin != null)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
IdleAmplitude = _perlin.m_AmplitudeGain;
|
||||
IdleFrequency = _perlin.m_FrequencyGain;
|
||||
#elif MM_CINEMACHINE3
|
||||
IdleAmplitude = _perlin.AmplitudeGain;
|
||||
IdleFrequency = _perlin.FrequencyGain;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
_targetAmplitude = IdleAmplitude;
|
||||
_targetFrequency = IdleFrequency;
|
||||
}
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
if (_perlin != null)
|
||||
{
|
||||
_perlin.m_AmplitudeGain = _targetAmplitude;
|
||||
_perlin.m_FrequencyGain = Mathf.Lerp(_perlin.m_FrequencyGain, _targetFrequency, GetDeltaTime() * LerpSpeed);
|
||||
}
|
||||
#elif MM_CINEMACHINE3
|
||||
if (_perlin != null)
|
||||
{
|
||||
_perlin.AmplitudeGain = _targetAmplitude;
|
||||
_perlin.FrequencyGain = Mathf.Lerp(_perlin.FrequencyGain, _targetFrequency, GetDeltaTime() * LerpSpeed);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this method to shake the camera for the specified duration (in seconds) with the default amplitude and frequency
|
||||
/// </summary>
|
||||
/// <param name="duration">Duration.</param>
|
||||
public virtual void ShakeCamera(float duration, bool infinite, bool useUnscaledTime = false)
|
||||
{
|
||||
StartCoroutine(ShakeCameraCo(duration, DefaultShakeAmplitude, DefaultShakeFrequency, infinite, useUnscaledTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use this method to shake the camera for the specified duration (in seconds), amplitude and frequency
|
||||
/// </summary>
|
||||
/// <param name="duration">Duration.</param>
|
||||
/// <param name="amplitude">Amplitude.</param>
|
||||
/// <param name="frequency">Frequency.</param>
|
||||
public virtual void ShakeCamera(float duration, float amplitude, float frequency, bool infinite, bool useUnscaledTime = false)
|
||||
{
|
||||
if (_shakeCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_shakeCoroutine);
|
||||
}
|
||||
_shakeCoroutine = StartCoroutine(ShakeCameraCo(duration, amplitude, frequency, infinite, useUnscaledTime));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This coroutine will shake the
|
||||
/// </summary>
|
||||
/// <returns>The camera co.</returns>
|
||||
/// <param name="duration">Duration.</param>
|
||||
/// <param name="amplitude">Amplitude.</param>
|
||||
/// <param name="frequency">Frequency.</param>
|
||||
protected virtual IEnumerator ShakeCameraCo(float duration, float amplitude, float frequency, bool infinite, bool useUnscaledTime)
|
||||
{
|
||||
_targetAmplitude = amplitude;
|
||||
_targetFrequency = frequency;
|
||||
_timescaleMode = useUnscaledTime ? TimescaleModes.Unscaled : TimescaleModes.Scaled;
|
||||
if (!infinite)
|
||||
{
|
||||
yield return MMCoroutine.WaitFor(duration);
|
||||
CameraReset();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the camera's noise values to their idle values
|
||||
/// </summary>
|
||||
public virtual void CameraReset()
|
||||
{
|
||||
_targetAmplitude = IdleAmplitude;
|
||||
_targetFrequency = IdleFrequency;
|
||||
}
|
||||
|
||||
public virtual void OnCameraShakeEvent(float duration, float amplitude, float frequency, float amplitudeX, float amplitudeY, float amplitudeZ, bool infinite, MMChannelData channelData, bool useUnscaledTime)
|
||||
{
|
||||
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
this.ShakeCamera(duration, amplitude, frequency, infinite, useUnscaledTime);
|
||||
}
|
||||
|
||||
public virtual void OnCameraShakeStopEvent(MMChannelData channelData)
|
||||
{
|
||||
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_shakeCoroutine != null)
|
||||
{
|
||||
StopCoroutine(_shakeCoroutine);
|
||||
}
|
||||
CameraReset();
|
||||
}
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
MMCameraShakeEvent.Register(OnCameraShakeEvent);
|
||||
MMCameraShakeStopEvent.Register(OnCameraShakeStopEvent);
|
||||
}
|
||||
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
MMCameraShakeEvent.Unregister(OnCameraShakeEvent);
|
||||
MMCameraShakeStopEvent.Unregister(OnCameraShakeStopEvent);
|
||||
}
|
||||
|
||||
protected virtual void TestShake()
|
||||
{
|
||||
MMCameraShakeEvent.Trigger(TestDuration, TestAmplitude, TestFrequency, 0f, 0f, 0f, false, new MMChannelData(ChannelMode, Channel, MMChannelDefinition));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d66462bf720d28469c8db4b2e52720c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineCameraShaker.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,233 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to a Cinemachine virtual camera and it'll let you control its near and far clipping planes
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Clipping Planes Shaker")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(CinemachineVirtualCamera))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineClippingPlanesShaker : MMShaker
|
||||
{
|
||||
[MMInspectorGroup("Clipping Planes", true, 45)]
|
||||
/// whether or not to add to the initial value
|
||||
public bool RelativeClippingPlanes = false;
|
||||
|
||||
[MMInspectorGroup("Near Plane", true, 46)]
|
||||
/// the curve used to animate the intensity value on
|
||||
[Tooltip("the curve used to animate the intensity value on")]
|
||||
public AnimationCurve ShakeNear = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
|
||||
/// the value to remap the curve's 0 to
|
||||
[Tooltip("the value to remap the curve's 0 to")]
|
||||
public float RemapNearZero = 0.3f;
|
||||
/// the value to remap the curve's 1 to
|
||||
[Tooltip("the value to remap the curve's 1 to")]
|
||||
public float RemapNearOne = 100f;
|
||||
|
||||
[MMInspectorGroup("Far Plane", true, 47)]
|
||||
/// the curve used to animate the intensity value on
|
||||
[Tooltip("the curve used to animate the intensity value on")]
|
||||
public AnimationCurve ShakeFar = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
|
||||
/// the value to remap the curve's 0 to
|
||||
[Tooltip("the value to remap the curve's 0 to")]
|
||||
public float RemapFarZero = 1000f;
|
||||
/// the value to remap the curve's 1 to
|
||||
[Tooltip("the value to remap the curve's 1 to")]
|
||||
public float RemapFarOne = 1000f;
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
protected CinemachineVirtualCamera _targetCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _targetCamera;
|
||||
#endif
|
||||
protected float _initialNear;
|
||||
protected float _initialFar;
|
||||
protected float _originalShakeDuration;
|
||||
protected bool _originalRelativeClippingPlanes;
|
||||
protected AnimationCurve _originalShakeNear;
|
||||
protected float _originalRemapNearZero;
|
||||
protected float _originalRemapNearOne;
|
||||
protected AnimationCurve _originalShakeFar;
|
||||
protected float _originalRemapFarZero;
|
||||
protected float _originalRemapFarOne;
|
||||
|
||||
/// <summary>
|
||||
/// On init we initialize our values
|
||||
/// </summary>
|
||||
protected override void Initialization()
|
||||
{
|
||||
base.Initialization();
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When that shaker gets added, we initialize its shake duration
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
{
|
||||
ShakeDuration = 0.5f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shakes values over time
|
||||
/// </summary>
|
||||
protected override void Shake()
|
||||
{
|
||||
float newNear = ShakeFloat(ShakeNear, RemapNearZero, RemapNearOne, RelativeClippingPlanes, _initialNear);
|
||||
float newFar = ShakeFloat(ShakeFar, RemapFarZero, RemapFarOne, RelativeClippingPlanes, _initialFar);
|
||||
SetNearFar(newNear, newFar);
|
||||
}
|
||||
|
||||
protected virtual void SetNearFar(float near, float far)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera.m_Lens.NearClipPlane = near;
|
||||
_targetCamera.m_Lens.FarClipPlane = far;
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera.Lens.NearClipPlane = near;
|
||||
_targetCamera.Lens.FarClipPlane = far;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collects initial values on the target
|
||||
/// </summary>
|
||||
protected override void GrabInitialValues()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_initialNear = _targetCamera.m_Lens.NearClipPlane;
|
||||
_initialFar = _targetCamera.m_Lens.FarClipPlane;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialNear = _targetCamera.Lens.NearClipPlane;
|
||||
_initialFar = _targetCamera.Lens.FarClipPlane;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we get the appropriate event, we trigger a shake
|
||||
/// </summary>
|
||||
/// <param name="distortionCurve"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="amplitude"></param>
|
||||
/// <param name="relativeDistortion"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
/// <param name="channel"></param>
|
||||
public virtual void OnMMCameraClippingPlanesShakeEvent(AnimationCurve animNearCurve, float duration, float remapNearMin, float remapNearMax, AnimationCurve animFarCurve, float remapFarMin, float remapFarMax, bool relativeValues = false,
|
||||
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
|
||||
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
|
||||
{
|
||||
if (!CheckEventAllowed(channelData))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stop)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (restore)
|
||||
{
|
||||
ResetTargetValues();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Interruptible && Shaking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
|
||||
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
|
||||
|
||||
if (resetShakerValuesAfterShake)
|
||||
{
|
||||
_originalShakeDuration = ShakeDuration;
|
||||
_originalShakeNear = ShakeNear;
|
||||
_originalShakeFar = ShakeFar;
|
||||
_originalRemapNearZero = RemapNearZero;
|
||||
_originalRemapNearOne = RemapNearOne;
|
||||
_originalRemapFarZero = RemapFarZero;
|
||||
_originalRemapFarOne = RemapFarOne;
|
||||
_originalRelativeClippingPlanes = RelativeClippingPlanes;
|
||||
}
|
||||
|
||||
if (!OnlyUseShakerValues)
|
||||
{
|
||||
TimescaleMode = timescaleMode;
|
||||
ShakeDuration = duration;
|
||||
ShakeNear = animNearCurve;
|
||||
RemapNearZero = remapNearMin * feedbacksIntensity;
|
||||
RemapNearOne = remapNearMax * feedbacksIntensity;
|
||||
ShakeFar = animFarCurve;
|
||||
RemapFarZero = remapFarMin * feedbacksIntensity;
|
||||
RemapFarOne = remapFarMax * feedbacksIntensity;
|
||||
RelativeClippingPlanes = relativeValues;
|
||||
ForwardDirection = forwardDirection;
|
||||
}
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the target's values
|
||||
/// </summary>
|
||||
protected override void ResetTargetValues()
|
||||
{
|
||||
base.ResetTargetValues();
|
||||
SetNearFar(_initialNear, _initialFar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the shaker's values
|
||||
/// </summary>
|
||||
protected override void ResetShakerValues()
|
||||
{
|
||||
base.ResetShakerValues();
|
||||
ShakeDuration = _originalShakeDuration;
|
||||
ShakeNear = _originalShakeNear;
|
||||
ShakeFar = _originalShakeFar;
|
||||
RemapNearZero = _originalRemapNearZero;
|
||||
RemapNearOne = _originalRemapNearOne;
|
||||
RemapFarZero = _originalRemapFarZero;
|
||||
RemapFarOne = _originalRemapFarOne;
|
||||
RelativeClippingPlanes = _originalRelativeClippingPlanes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for events
|
||||
/// </summary>
|
||||
public override void StartListening()
|
||||
{
|
||||
base.StartListening();
|
||||
MMCameraClippingPlanesShakeEvent.Register(OnMMCameraClippingPlanesShakeEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for events
|
||||
/// </summary>
|
||||
public override void StopListening()
|
||||
{
|
||||
base.StopListening();
|
||||
MMCameraClippingPlanesShakeEvent.Unregister(OnMMCameraClippingPlanesShakeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ff80f834f6ca564da816a2f08bc75f0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineClippingPlanesShaker.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,203 @@
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to a Cinemachine virtual camera and it'll let you control its field of view over time, can be piloted by a MMFeedbackCameraFieldOfView
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Field Of View Shaker")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(CinemachineVirtualCamera))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineFieldOfViewShaker : MMShaker
|
||||
{
|
||||
[MMInspectorGroup("Field of view", true, 41)]
|
||||
/// whether or not to add to the initial value
|
||||
[Tooltip("whether or not to add to the initial value")]
|
||||
public bool RelativeFieldOfView = false;
|
||||
/// the curve used to animate the intensity value on
|
||||
[Tooltip("the curve used to animate the intensity value on")]
|
||||
public AnimationCurve ShakeFieldOfView = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
|
||||
/// the value to remap the curve's 0 to
|
||||
[Tooltip("the value to remap the curve's 0 to")]
|
||||
[Range(0f, 179f)]
|
||||
public float RemapFieldOfViewZero = 60f;
|
||||
/// the value to remap the curve's 1 to
|
||||
[Tooltip("the value to remap the curve's 1 to")]
|
||||
[Range(0f, 179f)]
|
||||
public float RemapFieldOfViewOne = 120f;
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
protected CinemachineVirtualCamera _targetCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _targetCamera;
|
||||
#endif
|
||||
protected float _initialFieldOfView;
|
||||
protected float _originalShakeDuration;
|
||||
protected bool _originalRelativeFieldOfView;
|
||||
protected AnimationCurve _originalShakeFieldOfView;
|
||||
protected float _originalRemapFieldOfViewZero;
|
||||
protected float _originalRemapFieldOfViewOne;
|
||||
|
||||
/// <summary>
|
||||
/// On init we initialize our values
|
||||
/// </summary>
|
||||
protected override void Initialization()
|
||||
{
|
||||
base.Initialization();
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When that shaker gets added, we initialize its shake duration
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
{
|
||||
ShakeDuration = 0.5f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shakes values over time
|
||||
/// </summary>
|
||||
protected override void Shake()
|
||||
{
|
||||
float newFieldOfView = ShakeFloat(ShakeFieldOfView, RemapFieldOfViewZero, RemapFieldOfViewOne, RelativeFieldOfView, _initialFieldOfView);
|
||||
SetFieldOfView(newFieldOfView);
|
||||
}
|
||||
|
||||
protected virtual void SetFieldOfView(float newFieldOfView)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera.m_Lens.FieldOfView = newFieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera.Lens.FieldOfView = newFieldOfView;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collects initial values on the target
|
||||
/// </summary>
|
||||
protected override void GrabInitialValues()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_initialFieldOfView = _targetCamera.m_Lens.FieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialFieldOfView = _targetCamera.Lens.FieldOfView;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we get the appropriate event, we trigger a shake
|
||||
/// </summary>
|
||||
/// <param name="distortionCurve"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="amplitude"></param>
|
||||
/// <param name="relativeDistortion"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
/// <param name="channel"></param>
|
||||
public virtual void OnMMCameraFieldOfViewShakeEvent(AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
|
||||
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
|
||||
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
|
||||
{
|
||||
if (!CheckEventAllowed(channelData))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stop)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (restore)
|
||||
{
|
||||
ResetTargetValues();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Interruptible && Shaking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
|
||||
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
|
||||
|
||||
if (resetShakerValuesAfterShake)
|
||||
{
|
||||
_originalShakeDuration = ShakeDuration;
|
||||
_originalShakeFieldOfView = ShakeFieldOfView;
|
||||
_originalRemapFieldOfViewZero = RemapFieldOfViewZero;
|
||||
_originalRemapFieldOfViewOne = RemapFieldOfViewOne;
|
||||
_originalRelativeFieldOfView = RelativeFieldOfView;
|
||||
}
|
||||
|
||||
if (!OnlyUseShakerValues)
|
||||
{
|
||||
TimescaleMode = timescaleMode;
|
||||
ShakeDuration = duration;
|
||||
ShakeFieldOfView = distortionCurve;
|
||||
RemapFieldOfViewZero = remapMin * feedbacksIntensity;
|
||||
RemapFieldOfViewOne = remapMax * feedbacksIntensity;
|
||||
RelativeFieldOfView = relativeDistortion;
|
||||
ForwardDirection = forwardDirection;
|
||||
}
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the target's values
|
||||
/// </summary>
|
||||
protected override void ResetTargetValues()
|
||||
{
|
||||
base.ResetTargetValues();
|
||||
SetFieldOfView(_initialFieldOfView);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the shaker's values
|
||||
/// </summary>
|
||||
protected override void ResetShakerValues()
|
||||
{
|
||||
base.ResetShakerValues();
|
||||
ShakeDuration = _originalShakeDuration;
|
||||
ShakeFieldOfView = _originalShakeFieldOfView;
|
||||
RemapFieldOfViewZero = _originalRemapFieldOfViewZero;
|
||||
RemapFieldOfViewOne = _originalRemapFieldOfViewOne;
|
||||
RelativeFieldOfView = _originalRelativeFieldOfView;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for events
|
||||
/// </summary>
|
||||
public override void StartListening()
|
||||
{
|
||||
base.StartListening();
|
||||
MMCameraFieldOfViewShakeEvent.Register(OnMMCameraFieldOfViewShakeEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for events
|
||||
/// </summary>
|
||||
public override void StopListening()
|
||||
{
|
||||
base.StopListening();
|
||||
MMCameraFieldOfViewShakeEvent.Unregister(OnMMCameraFieldOfViewShakeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d68394ff0deaba948873307b5fe5a801
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineFieldOfViewShaker.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,257 @@
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// This class will allow you to trigger zooms on your cinemachine camera by sending MMCameraZoomEvents from any other class
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Free Look Zoom")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(Cinemachine.CinemachineFreeLook))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineFreeLookZoom : MonoBehaviour
|
||||
{
|
||||
[Header("Channel")]
|
||||
[MMFInspectorGroup("Shaker Settings", true, 3)]
|
||||
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
|
||||
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
|
||||
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
|
||||
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
|
||||
public MMChannelModes ChannelMode = MMChannelModes.Int;
|
||||
/// the channel to listen to - has to match the one on the feedback
|
||||
[Tooltip("the channel to listen to - has to match the one on the feedback")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
|
||||
public int Channel = 0;
|
||||
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
|
||||
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
|
||||
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
|
||||
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
|
||||
public MMChannel MMChannelDefinition = null;
|
||||
|
||||
[Header("Transition Speed")]
|
||||
/// the animation curve to apply to the zoom transition
|
||||
[Tooltip("the animation curve to apply to the zoom transition")]
|
||||
public MMTweenType ZoomTween = new MMTweenType( new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)));
|
||||
|
||||
[Header("Test Zoom")]
|
||||
/// the mode to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the mode to apply the zoom in when using the test button in the inspector")]
|
||||
public MMCameraZoomModes TestMode;
|
||||
/// the target field of view to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the target field of view to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestFieldOfView = 30f;
|
||||
/// the transition duration to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the transition duration to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestTransitionDuration = 0.1f;
|
||||
/// the duration to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the duration to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestDuration = 0.05f;
|
||||
|
||||
[MMFInspectorButton("TestZoom")]
|
||||
/// an inspector button to test the zoom in play mode
|
||||
public bool TestZoomButton;
|
||||
|
||||
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
|
||||
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
|
||||
|
||||
public virtual TimescaleModes TimescaleMode { get; set; }
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
protected Cinemachine.CinemachineFreeLook _freeLookCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _freeLookCamera;
|
||||
#endif
|
||||
protected float _initialFieldOfView;
|
||||
protected MMCameraZoomModes _mode;
|
||||
protected bool _zooming = false;
|
||||
protected float _startFieldOfView;
|
||||
protected float _transitionDuration;
|
||||
protected float _duration;
|
||||
protected float _targetFieldOfView;
|
||||
protected float _delta = 0f;
|
||||
protected int _direction = 1;
|
||||
protected float _reachedDestinationTimestamp;
|
||||
protected bool _destinationReached = false;
|
||||
protected float _elapsedTime = 0f;
|
||||
protected float _zoomStartedAt = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// On Awake we grab our virtual camera
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_freeLookCamera = this.gameObject.GetComponent<Cinemachine.CinemachineFreeLook>();
|
||||
_initialFieldOfView = _freeLookCamera.m_Lens.FieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_freeLookCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
_initialFieldOfView = _freeLookCamera.Lens.FieldOfView;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Update if we're zooming we modify our field of view accordingly
|
||||
/// </summary>
|
||||
protected virtual void Update()
|
||||
{
|
||||
if (!_zooming)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_elapsedTime = GetTime() - _zoomStartedAt;
|
||||
if (_elapsedTime <= _transitionDuration)
|
||||
{
|
||||
float t = MMMaths.Remap(_elapsedTime, 0f, _transitionDuration, 0f, 1f);
|
||||
#if MM_CINEMACHINE
|
||||
_freeLookCamera.m_Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomTween.Evaluate(t));
|
||||
#elif MM_CINEMACHINE3
|
||||
_freeLookCamera.Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomTween.Evaluate(t));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_destinationReached)
|
||||
{
|
||||
_reachedDestinationTimestamp = GetTime();
|
||||
_destinationReached = true;
|
||||
}
|
||||
if ((_mode == MMCameraZoomModes.For) && (_direction == 1))
|
||||
{
|
||||
if (GetTime() - _reachedDestinationTimestamp > _duration)
|
||||
{
|
||||
_direction = -1;
|
||||
_zoomStartedAt = GetTime();
|
||||
_startFieldOfView = _targetFieldOfView;
|
||||
_targetFieldOfView = _initialFieldOfView;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_zooming = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method that triggers the zoom, ideally only to be called via an event, but public for convenience
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <param name="newFieldOfView"></param>
|
||||
/// <param name="transitionDuration"></param>
|
||||
/// <param name="duration"></param>
|
||||
public virtual void Zoom(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration,
|
||||
float duration, bool relative = false, MMTweenType tweenType = null)
|
||||
{
|
||||
if (_zooming)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_zooming = true;
|
||||
_elapsedTime = 0f;
|
||||
_mode = mode;
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
_startFieldOfView = _freeLookCamera.m_Lens.FieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_startFieldOfView = _freeLookCamera.Lens.FieldOfView;
|
||||
#endif
|
||||
|
||||
_transitionDuration = transitionDuration;
|
||||
_duration = duration;
|
||||
_transitionDuration = transitionDuration;
|
||||
_direction = 1;
|
||||
_destinationReached = false;
|
||||
_zoomStartedAt = GetTime();
|
||||
|
||||
if (tweenType != null)
|
||||
{
|
||||
ZoomTween = tweenType;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case MMCameraZoomModes.For:
|
||||
_targetFieldOfView = newFieldOfView;
|
||||
break;
|
||||
|
||||
case MMCameraZoomModes.Set:
|
||||
_targetFieldOfView = newFieldOfView;
|
||||
break;
|
||||
|
||||
case MMCameraZoomModes.Reset:
|
||||
_targetFieldOfView = _initialFieldOfView;
|
||||
break;
|
||||
}
|
||||
|
||||
if (relative)
|
||||
{
|
||||
_targetFieldOfView += _initialFieldOfView;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method used by the test button to trigger a test zoom
|
||||
/// </summary>
|
||||
protected virtual void TestZoom()
|
||||
{
|
||||
Zoom(TestMode, TestFieldOfView, TestTransitionDuration, TestDuration);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we get an MMCameraZoomEvent we call our zoom method
|
||||
/// </summary>
|
||||
/// <param name="zoomEvent"></param>
|
||||
public virtual void OnCameraZoomEvent(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration,
|
||||
MMChannelData channelData, bool useUnscaledTime, bool stop = false, bool relative = false, bool restore = false, MMTweenType tweenType = null)
|
||||
{
|
||||
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (stop)
|
||||
{
|
||||
_zooming = false;
|
||||
return;
|
||||
}
|
||||
if (restore)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_freeLookCamera.m_Lens.FieldOfView = _initialFieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_freeLookCamera.Lens.FieldOfView = _initialFieldOfView;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
this.Zoom(mode, newFieldOfView, transitionDuration, duration, relative, tweenType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for MMCameraZoomEvents
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
MMCameraZoomEvent.Register(OnCameraZoomEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for MMCameraZoomEvents
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
MMCameraZoomEvent.Unregister(OnCameraZoomEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5c6086564eb2a44db13fc3cd3a66644
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineFreeLookZoom.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,200 @@
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to a Cinemachine virtual camera and it'll let you control its orthographic size over time, can be piloted by a MMFeedbackCameraOrthographicSize
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Orthographic Size Shaker")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(CinemachineVirtualCamera))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineOrthographicSizeShaker : MMShaker
|
||||
{
|
||||
[MMInspectorGroup("Orthographic Size", true, 43)]
|
||||
/// whether or not to add to the initial value
|
||||
[Tooltip("whether or not to add to the initial value")]
|
||||
public bool RelativeOrthographicSize = false;
|
||||
/// the curve used to animate the intensity value on
|
||||
[Tooltip("the curve used to animate the intensity value on")]
|
||||
public AnimationCurve ShakeOrthographicSize = new AnimationCurve(new Keyframe(0, 0), new Keyframe(0.5f, 1), new Keyframe(1, 0));
|
||||
/// the value to remap the curve's 0 to
|
||||
[Tooltip("the value to remap the curve's 0 to")]
|
||||
public float RemapOrthographicSizeZero = 5f;
|
||||
/// the value to remap the curve's 1 to
|
||||
[Tooltip("the value to remap the curve's 1 to")]
|
||||
public float RemapOrthographicSizeOne = 10f;
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
protected CinemachineVirtualCamera _targetCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _targetCamera;
|
||||
#endif
|
||||
protected float _initialOrthographicSize;
|
||||
protected float _originalShakeDuration;
|
||||
protected bool _originalRelativeOrthographicSize;
|
||||
protected AnimationCurve _originalShakeOrthographicSize;
|
||||
protected float _originalRemapOrthographicSizeZero;
|
||||
protected float _originalRemapOrthographicSizeOne;
|
||||
|
||||
/// <summary>
|
||||
/// On init we initialize our values
|
||||
/// </summary>
|
||||
protected override void Initialization()
|
||||
{
|
||||
base.Initialization();
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineVirtualCamera>();
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When that shaker gets added, we initialize its shake duration
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
{
|
||||
ShakeDuration = 0.5f;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shakes values over time
|
||||
/// </summary>
|
||||
protected override void Shake()
|
||||
{
|
||||
float newOrthographicSize = ShakeFloat(ShakeOrthographicSize, RemapOrthographicSizeZero, RemapOrthographicSizeOne, RelativeOrthographicSize, _initialOrthographicSize);
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera.m_Lens.OrthographicSize = newOrthographicSize;
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera.Lens.OrthographicSize = newOrthographicSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Collects initial values on the target
|
||||
/// </summary>
|
||||
protected override void GrabInitialValues()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_initialOrthographicSize = _targetCamera.m_Lens.OrthographicSize;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialOrthographicSize = _targetCamera.Lens.OrthographicSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we get the appropriate event, we trigger a shake
|
||||
/// </summary>
|
||||
/// <param name="distortionCurve"></param>
|
||||
/// <param name="duration"></param>
|
||||
/// <param name="amplitude"></param>
|
||||
/// <param name="relativeDistortion"></param>
|
||||
/// <param name="feedbacksIntensity"></param>
|
||||
/// <param name="channel"></param>
|
||||
public virtual void OnMMCameraOrthographicSizeShakeEvent(AnimationCurve distortionCurve, float duration, float remapMin, float remapMax, bool relativeDistortion = false,
|
||||
float feedbacksIntensity = 1.0f, MMChannelData channelData = null, bool resetShakerValuesAfterShake = true, bool resetTargetValuesAfterShake = true, bool forwardDirection = true,
|
||||
TimescaleModes timescaleMode = TimescaleModes.Scaled, bool stop = false, bool restore = false)
|
||||
{
|
||||
if (!CheckEventAllowed(channelData))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (stop)
|
||||
{
|
||||
Stop();
|
||||
return;
|
||||
}
|
||||
|
||||
if (restore)
|
||||
{
|
||||
ResetTargetValues();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Interruptible && Shaking)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_resetShakerValuesAfterShake = resetShakerValuesAfterShake;
|
||||
_resetTargetValuesAfterShake = resetTargetValuesAfterShake;
|
||||
|
||||
if (resetShakerValuesAfterShake)
|
||||
{
|
||||
_originalShakeDuration = ShakeDuration;
|
||||
_originalShakeOrthographicSize = ShakeOrthographicSize;
|
||||
_originalRemapOrthographicSizeZero = RemapOrthographicSizeZero;
|
||||
_originalRemapOrthographicSizeOne = RemapOrthographicSizeOne;
|
||||
_originalRelativeOrthographicSize = RelativeOrthographicSize;
|
||||
}
|
||||
|
||||
if (!OnlyUseShakerValues)
|
||||
{
|
||||
TimescaleMode = timescaleMode;
|
||||
ShakeDuration = duration;
|
||||
ShakeOrthographicSize = distortionCurve;
|
||||
RemapOrthographicSizeZero = remapMin * feedbacksIntensity;
|
||||
RemapOrthographicSizeOne = remapMax * feedbacksIntensity;
|
||||
RelativeOrthographicSize = relativeDistortion;
|
||||
ForwardDirection = forwardDirection;
|
||||
}
|
||||
|
||||
Play();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the target's values
|
||||
/// </summary>
|
||||
protected override void ResetTargetValues()
|
||||
{
|
||||
base.ResetTargetValues();
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera.m_Lens.OrthographicSize = _initialOrthographicSize;
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera.Lens.OrthographicSize = _initialOrthographicSize;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the shaker's values
|
||||
/// </summary>
|
||||
protected override void ResetShakerValues()
|
||||
{
|
||||
base.ResetShakerValues();
|
||||
ShakeDuration = _originalShakeDuration;
|
||||
ShakeOrthographicSize = _originalShakeOrthographicSize;
|
||||
RemapOrthographicSizeZero = _originalRemapOrthographicSizeZero;
|
||||
RemapOrthographicSizeOne = _originalRemapOrthographicSizeOne;
|
||||
RelativeOrthographicSize = _originalRelativeOrthographicSize;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts listening for events
|
||||
/// </summary>
|
||||
public override void StartListening()
|
||||
{
|
||||
base.StartListening();
|
||||
MMCameraOrthographicSizeShakeEvent.Register(OnMMCameraOrthographicSizeShakeEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for events
|
||||
/// </summary>
|
||||
public override void StopListening()
|
||||
{
|
||||
base.StopListening();
|
||||
MMCameraOrthographicSizeShakeEvent.Unregister(OnMMCameraOrthographicSizeShakeEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0aded04d7fa45744fb33cc0a43b0d6ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineOrthographicSizeShaker.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,133 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to a Cinemachine brain and it'll be able to accept custom blend transitions (used with MMFeedbackCinemachineTransition)
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Priority Brain Listener")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineBrain))]
|
||||
#endif
|
||||
public class MMCinemachinePriorityBrainListener : MonoBehaviour
|
||||
{
|
||||
|
||||
[HideInInspector]
|
||||
public TimescaleModes TimescaleMode = TimescaleModes.Scaled;
|
||||
|
||||
|
||||
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
|
||||
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
protected CinemachineBrain _brain;
|
||||
protected CinemachineBlendDefinition _initialDefinition;
|
||||
#endif
|
||||
protected Coroutine _coroutine;
|
||||
|
||||
/// <summary>
|
||||
/// On Awake we grab our brain
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
_brain = this.gameObject.GetComponent<CinemachineBrain>();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
/// <summary>
|
||||
/// When getting an event we change our default transition if needed
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="forceMaxPriority"></param>
|
||||
/// <param name="newPriority"></param>
|
||||
/// <param name="forceTransition"></param>
|
||||
/// <param name="blendDefinition"></param>
|
||||
/// <param name="resetValuesAfterTransition"></param>
|
||||
public virtual void OnMMCinemachinePriorityEvent(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
|
||||
{
|
||||
if (forceTransition)
|
||||
{
|
||||
if (_coroutine != null)
|
||||
{
|
||||
StopCoroutine(_coroutine);
|
||||
}
|
||||
else
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_initialDefinition = _brain.m_DefaultBlend;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialDefinition = _brain.DefaultBlend;
|
||||
#endif
|
||||
}
|
||||
#if MM_CINEMACHINE
|
||||
_brain.m_DefaultBlend = blendDefinition;
|
||||
#elif MM_CINEMACHINE3
|
||||
_brain.DefaultBlend = blendDefinition;
|
||||
#endif
|
||||
TimescaleMode = timescaleMode;
|
||||
#if MM_CINEMACHINE
|
||||
_coroutine = StartCoroutine(ResetBlendDefinition(blendDefinition.m_Time));
|
||||
#elif MM_CINEMACHINE3
|
||||
_coroutine = StartCoroutine(ResetBlendDefinition(blendDefinition.Time));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// a coroutine used to reset the default transition to its initial value
|
||||
/// </summary>
|
||||
/// <param name="delay"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual IEnumerator ResetBlendDefinition(float delay)
|
||||
{
|
||||
yield return null;
|
||||
yield return null;
|
||||
for (float timer = 0; timer < delay; timer += GetDeltaTime())
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
#if MM_CINEMACHINE
|
||||
_brain.m_DefaultBlend = _initialDefinition;
|
||||
#elif MM_CINEMACHINE3
|
||||
_brain.DefaultBlend = _initialDefinition;
|
||||
#endif
|
||||
_coroutine = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we start listening for events
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
_coroutine = null;
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
MMCinemachinePriorityEvent.Register(OnMMCinemachinePriorityEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for events
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
if (_coroutine != null)
|
||||
{
|
||||
StopCoroutine(_coroutine);
|
||||
}
|
||||
_coroutine = null;
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
MMCinemachinePriorityEvent.Unregister(OnMMCinemachinePriorityEvent);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2436c2ba147129746badf6cfa2ee2d1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachinePriorityBrainListener.cs
|
||||
uploadId: 830868
|
||||
@@ -0,0 +1,158 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to a Cinemachine virtual camera and it'll be able to listen to MMCinemachinePriorityEvent, usually triggered by a MMFeedbackCinemachineTransition
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Priority Listener")]
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineVirtualCameraBase))]
|
||||
#endif
|
||||
public class MMCinemachinePriorityListener : MonoBehaviour
|
||||
{
|
||||
|
||||
[HideInInspector]
|
||||
public TimescaleModes TimescaleMode = TimescaleModes.Scaled;
|
||||
|
||||
|
||||
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
|
||||
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
|
||||
|
||||
[Header("Priority Listener")]
|
||||
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
|
||||
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
|
||||
public MMChannelModes ChannelMode = MMChannelModes.Int;
|
||||
/// the channel to listen to - has to match the one on the feedback
|
||||
[Tooltip("the channel to listen to - has to match the one on the feedback")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
|
||||
public int Channel = 0;
|
||||
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
|
||||
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
|
||||
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
|
||||
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
|
||||
public MMChannel MMChannelDefinition = null;
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
protected CinemachineVirtualCameraBase _camera;
|
||||
protected int _initialPriority;
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// On Awake we store our virtual camera
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
_camera = this.gameObject.GetComponent<CinemachineVirtualCameraBase>();
|
||||
#endif
|
||||
#if MM_CINEMACHINE
|
||||
_initialPriority = _camera.Priority;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialPriority = _camera.Priority.Value;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
/// <summary>
|
||||
/// When we get an event we change our priorities if needed
|
||||
/// </summary>
|
||||
/// <param name="channel"></param>
|
||||
/// <param name="forceMaxPriority"></param>
|
||||
/// <param name="newPriority"></param>
|
||||
/// <param name="forceTransition"></param>
|
||||
/// <param name="blendDefinition"></param>
|
||||
/// <param name="resetValuesAfterTransition"></param>
|
||||
public virtual void OnMMCinemachinePriorityEvent(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
|
||||
{
|
||||
StartCoroutine(OnMMCinemachinePriorityEventCo(channelData, forceMaxPriority, newPriority, forceTransition,
|
||||
blendDefinition, resetValuesAfterTransition, timescaleMode, restore));
|
||||
}
|
||||
|
||||
protected virtual IEnumerator OnMMCinemachinePriorityEventCo(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
|
||||
{
|
||||
yield return null;
|
||||
TimescaleMode = timescaleMode;
|
||||
if (MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
|
||||
{
|
||||
if (restore)
|
||||
{
|
||||
SetPriority(_initialPriority);
|
||||
yield break;
|
||||
}
|
||||
SetPriority(newPriority);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (forceMaxPriority)
|
||||
{
|
||||
if (restore)
|
||||
{
|
||||
SetPriority(_initialPriority);
|
||||
yield break;;
|
||||
}
|
||||
SetPriority(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected virtual void SetPriority(int newPriority)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_camera.Priority = newPriority;
|
||||
#elif MM_CINEMACHINE3
|
||||
PrioritySettings prioritySettings = _camera.Priority;
|
||||
prioritySettings.Value = newPriority;
|
||||
_camera.Priority = prioritySettings;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On enable we start listening for events
|
||||
/// </summary>
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
MMCinemachinePriorityEvent.Register(OnMMCinemachinePriorityEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for events
|
||||
/// </summary>
|
||||
protected virtual void OnDisable()
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
MMCinemachinePriorityEvent.Unregister(OnMMCinemachinePriorityEvent);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An event used to pilot priorities on cinemachine virtual cameras and brain transitions
|
||||
/// </summary>
|
||||
public struct MMCinemachinePriorityEvent
|
||||
{
|
||||
#if MM_CINEMACHINE || MM_CINEMACHINE3
|
||||
static private event Delegate OnEvent;
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)] private static void RuntimeInitialization() { OnEvent = null; }
|
||||
static public void Register(Delegate callback) { OnEvent += callback; }
|
||||
static public void Unregister(Delegate callback) { OnEvent -= callback; }
|
||||
|
||||
public delegate void Delegate(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false);
|
||||
static public void Trigger(MMChannelData channelData, bool forceMaxPriority, int newPriority, bool forceTransition, CinemachineBlendDefinition blendDefinition, bool resetValuesAfterTransition, TimescaleModes timescaleMode, bool restore = false)
|
||||
{
|
||||
OnEvent?.Invoke(channelData, forceMaxPriority, newPriority, forceTransition, blendDefinition, resetValuesAfterTransition, timescaleMode, restore);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f8650a79a9f5e38449718559d1d6a2f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachinePriorityListener.cs
|
||||
uploadId: 830868
|
||||
245
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineZoom.cs
vendored
Normal file
245
Assets/External/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineZoom.cs
vendored
Normal file
@@ -0,0 +1,245 @@
|
||||
using UnityEngine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
using Unity.Cinemachine;
|
||||
#endif
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
|
||||
namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
/// <summary>
|
||||
/// This class will allow you to trigger zooms on your cinemachine camera by sending MMCameraZoomEvents from any other class
|
||||
/// </summary>
|
||||
[AddComponentMenu("More Mountains/Feedbacks/Shakers/Cinemachine/MM Cinemachine Zoom")]
|
||||
#if MM_CINEMACHINE
|
||||
[RequireComponent(typeof(Cinemachine.CinemachineVirtualCamera))]
|
||||
#elif MM_CINEMACHINE3
|
||||
[RequireComponent(typeof(CinemachineCamera))]
|
||||
#endif
|
||||
public class MMCinemachineZoom : MonoBehaviour
|
||||
{
|
||||
[Header("Channel")]
|
||||
[MMFInspectorGroup("Shaker Settings", true, 3)]
|
||||
/// whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what.
|
||||
/// MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable
|
||||
[Tooltip("whether to listen on a channel defined by an int or by a MMChannel scriptable object. Ints are simple to setup but can get messy and make it harder to remember what int corresponds to what. " +
|
||||
"MMChannel scriptable objects require you to create them in advance, but come with a readable name and are more scalable")]
|
||||
public MMChannelModes ChannelMode = MMChannelModes.Int;
|
||||
/// the channel to listen to - has to match the one on the feedback
|
||||
[Tooltip("the channel to listen to - has to match the one on the feedback")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.Int)]
|
||||
public int Channel = 0;
|
||||
/// the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel,
|
||||
/// right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name
|
||||
[Tooltip("the MMChannel definition asset to use to listen for events. The feedbacks targeting this shaker will have to reference that same MMChannel definition to receive events - to create a MMChannel, " +
|
||||
"right click anywhere in your project (usually in a Data folder) and go MoreMountains > MMChannel, then name it with some unique name")]
|
||||
[MMFEnumCondition("ChannelMode", (int)MMChannelModes.MMChannel)]
|
||||
public MMChannel MMChannelDefinition = null;
|
||||
/// if this is true, triggering a new zoom event will interrupt any transition that may be in progress
|
||||
[Tooltip("if this is true, triggering a new zoom event will interrupt any transition that may be in progress")]
|
||||
public bool Interruptable = false;
|
||||
|
||||
[Header("Transition Speed")]
|
||||
/// the animation curve to apply to the zoom transition
|
||||
[Tooltip("the animation curve to apply to the zoom transition")]
|
||||
public MMTweenType ZoomTween = new MMTweenType( new AnimationCurve(new Keyframe(0f, 0f), new Keyframe(1f, 1f)));
|
||||
|
||||
[Header("Test Zoom")]
|
||||
/// the mode to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the mode to apply the zoom in when using the test button in the inspector")]
|
||||
public MMCameraZoomModes TestMode;
|
||||
/// the target field of view to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the target field of view to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestFieldOfView = 30f;
|
||||
/// the transition duration to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the transition duration to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestTransitionDuration = 0.1f;
|
||||
/// the duration to apply the zoom in when using the test button in the inspector
|
||||
[Tooltip("the duration to apply the zoom in when using the test button in the inspector")]
|
||||
public float TestDuration = 0.05f;
|
||||
|
||||
[MMFInspectorButton("TestZoom")]
|
||||
/// an inspector button to test the zoom in play mode
|
||||
public bool TestZoomButton;
|
||||
|
||||
public virtual float GetTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.time : Time.unscaledTime; }
|
||||
public virtual float GetDeltaTime() { return (TimescaleMode == TimescaleModes.Scaled) ? Time.deltaTime : Time.unscaledDeltaTime; }
|
||||
|
||||
public virtual TimescaleModes TimescaleMode { get; set; }
|
||||
|
||||
#if MM_CINEMACHINE
|
||||
protected Cinemachine.CinemachineVirtualCamera _virtualCamera;
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _virtualCamera;
|
||||
#endif
|
||||
protected float _initialFieldOfView;
|
||||
protected MMCameraZoomModes _mode;
|
||||
protected float _startFieldOfView;
|
||||
protected float _transitionDuration;
|
||||
protected float _duration;
|
||||
protected float _targetFieldOfView;
|
||||
protected float _elapsedTime = 0f;
|
||||
protected int _direction = 1;
|
||||
protected float _reachedDestinationTimestamp;
|
||||
protected bool _destinationReached = false;
|
||||
protected float _zoomStartedAt = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// On Awake we grab our virtual camera
|
||||
/// </summary>
|
||||
protected virtual void Awake()
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_virtualCamera = this.gameObject.GetComponent<Cinemachine.CinemachineVirtualCamera>();
|
||||
_initialFieldOfView = _virtualCamera.m_Lens.FieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_virtualCamera = this.gameObject.GetComponent<CinemachineCamera>();
|
||||
_initialFieldOfView = _virtualCamera.Lens.FieldOfView;
|
||||
#endif
|
||||
MMCameraZoomEvent.Register(OnCameraZoomEvent);
|
||||
this.enabled = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On Update if we're zooming we modify our field of view accordingly
|
||||
/// </summary>
|
||||
protected virtual void Update()
|
||||
{
|
||||
_elapsedTime = GetTime() - _zoomStartedAt;
|
||||
if (_elapsedTime <= _transitionDuration)
|
||||
{
|
||||
float t = MMMaths.Remap(_elapsedTime, 0f, _transitionDuration, 0f, 1f);
|
||||
#if MM_CINEMACHINE
|
||||
_virtualCamera.m_Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomTween.Evaluate(t));
|
||||
#elif MM_CINEMACHINE3
|
||||
_virtualCamera.Lens.FieldOfView = Mathf.LerpUnclamped(_startFieldOfView, _targetFieldOfView, ZoomTween.Evaluate(t));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!_destinationReached)
|
||||
{
|
||||
_reachedDestinationTimestamp = GetTime();
|
||||
_destinationReached = true;
|
||||
}
|
||||
if ((_mode == MMCameraZoomModes.For) && (_direction == 1))
|
||||
{
|
||||
if (GetTime() - _reachedDestinationTimestamp > _duration)
|
||||
{
|
||||
_direction = -1;
|
||||
_zoomStartedAt = GetTime();
|
||||
_startFieldOfView = _targetFieldOfView;
|
||||
_targetFieldOfView = _initialFieldOfView;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.enabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A method that triggers the zoom, ideally only to be called via an event, but public for convenience
|
||||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <param name="newFieldOfView"></param>
|
||||
/// <param name="transitionDuration"></param>
|
||||
/// <param name="duration"></param>
|
||||
public virtual void Zoom(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, bool useUnscaledTime, bool relative = false, MMTweenType tweenType = null)
|
||||
{
|
||||
if (this.enabled && !Interruptable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.enabled = true;
|
||||
_elapsedTime = 0f;
|
||||
_mode = mode;
|
||||
|
||||
TimescaleMode = useUnscaledTime ? TimescaleModes.Unscaled : TimescaleModes.Scaled;
|
||||
#if MM_CINEMACHINE
|
||||
_startFieldOfView = _virtualCamera.m_Lens.FieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_startFieldOfView = _virtualCamera.Lens.FieldOfView;
|
||||
#endif
|
||||
_transitionDuration = transitionDuration;
|
||||
_duration = duration;
|
||||
_transitionDuration = transitionDuration;
|
||||
_direction = 1;
|
||||
_destinationReached = false;
|
||||
_zoomStartedAt = GetTime();
|
||||
|
||||
if (tweenType != null)
|
||||
{
|
||||
ZoomTween = tweenType;
|
||||
}
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case MMCameraZoomModes.For:
|
||||
_targetFieldOfView = newFieldOfView;
|
||||
break;
|
||||
|
||||
case MMCameraZoomModes.Set:
|
||||
_targetFieldOfView = newFieldOfView;
|
||||
break;
|
||||
|
||||
case MMCameraZoomModes.Reset:
|
||||
_targetFieldOfView = _initialFieldOfView;
|
||||
break;
|
||||
}
|
||||
|
||||
if (relative)
|
||||
{
|
||||
_targetFieldOfView += _initialFieldOfView;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The method used by the test button to trigger a test zoom
|
||||
/// </summary>
|
||||
protected virtual void TestZoom()
|
||||
{
|
||||
Zoom(TestMode, TestFieldOfView, TestTransitionDuration, TestDuration, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// When we get an MMCameraZoomEvent we call our zoom method
|
||||
/// </summary>
|
||||
/// <param name="zoomEvent"></param>
|
||||
public virtual void OnCameraZoomEvent(MMCameraZoomModes mode, float newFieldOfView, float transitionDuration, float duration, MMChannelData channelData,
|
||||
bool useUnscaledTime, bool stop = false, bool relative = false, bool restore = false, MMTweenType tweenType = null)
|
||||
{
|
||||
if (!MMChannel.Match(channelData, ChannelMode, Channel, MMChannelDefinition))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (stop)
|
||||
{
|
||||
this.enabled = false;
|
||||
return;
|
||||
}
|
||||
if (restore)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_virtualCamera.m_Lens.FieldOfView = _initialFieldOfView;
|
||||
#elif MM_CINEMACHINE3
|
||||
_virtualCamera.Lens.FieldOfView = _initialFieldOfView;
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
this.Zoom(mode, newFieldOfView, transitionDuration, duration, useUnscaledTime, relative, tweenType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops listening for MMCameraZoomEvents
|
||||
/// </summary>
|
||||
protected virtual void OnDestroy()
|
||||
{
|
||||
MMCameraZoomEvent.Unregister(OnCameraZoomEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51662a222e352d74a8ad12e5843f7501
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 183370
|
||||
packageName: Feel
|
||||
packageVersion: 5.9.1
|
||||
assetPath: Assets/Feel/MMFeedbacks/MMFeedbacksForThirdParty/Cinemachine/Shakers/MMCinemachineZoom.cs
|
||||
uploadId: 830868
|
||||
Reference in New Issue
Block a user