整合SLSUtilities
This commit is contained in:
@@ -2,6 +2,7 @@ using UnityEngine;
|
||||
using MoreMountains.Feedbacks;
|
||||
using MoreMountains.Tools;
|
||||
using System.Collections.Generic;
|
||||
using SLSUtilities.Cinemachine;
|
||||
#if MM_CINEMACHINE
|
||||
using Cinemachine;
|
||||
#elif MM_CINEMACHINE3
|
||||
@@ -62,8 +63,6 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
#endif
|
||||
public class MMCinemachineRotationShaker : MMShaker
|
||||
{
|
||||
public Transform FollowTarget => _targetCamera.Follow;
|
||||
|
||||
[MMInspectorGroup("Debug Info", true, 43)]
|
||||
[MMReadOnly]
|
||||
public int ActiveShakesCount = 0;
|
||||
@@ -73,9 +72,9 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
#elif MM_CINEMACHINE3
|
||||
protected CinemachineCamera _targetCamera;
|
||||
#endif
|
||||
|
||||
protected float _initialDutch;
|
||||
protected Quaternion _initialTargetRotation;
|
||||
|
||||
protected CinemachineRotationOffset _rotationOffset;
|
||||
protected Vector3 _initialTargetRotation;
|
||||
|
||||
// 活跃震动列表
|
||||
protected List<MMCinemachineRotationShakeInstance> _activeShakes = new List<MMCinemachineRotationShakeInstance>();
|
||||
@@ -85,8 +84,10 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
// 不调用 base.Initialization() 以完全接管 Update 逻辑
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera = GetComponent<CinemachineVirtualCamera>();
|
||||
_rotationOffset = GetComponent<CinemachineRotationOffset>();
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera = GetComponent<CinemachineCamera>();
|
||||
_rotationOffset = GetComponent<CinemachineRotationOffset>();
|
||||
#endif
|
||||
GrabInitialValues();
|
||||
}
|
||||
@@ -95,16 +96,7 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
{
|
||||
if (_targetCamera != null)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_initialDutch = _targetCamera.m_Lens.Dutch;
|
||||
#elif MM_CINEMACHINE3
|
||||
_initialDutch = _targetCamera.Lens.Dutch;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (FollowTarget != null)
|
||||
{
|
||||
_initialTargetRotation = FollowTarget.localRotation;
|
||||
_initialTargetRotation = _rotationOffset.rotationOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,22 +154,7 @@ namespace MoreMountains.FeedbacksForThirdParty
|
||||
|
||||
protected virtual void ApplyRotation(float xOffset, float yOffset, float zOffset)
|
||||
{
|
||||
// Z -> Dutch (直接加法)
|
||||
if (_targetCamera != null)
|
||||
{
|
||||
#if MM_CINEMACHINE
|
||||
_targetCamera.m_Lens.Dutch = _initialDutch + zOffset;
|
||||
#elif MM_CINEMACHINE3
|
||||
_targetCamera.Lens.Dutch = _initialDutch + zOffset;
|
||||
#endif
|
||||
}
|
||||
|
||||
// X/Y -> FollowTarget (Quaternion 乘法)
|
||||
if (FollowTarget != null)
|
||||
{
|
||||
// 注意:这里我们将叠加后的 Euler 角度转换为 Quaternion,然后应用到初始旋转上
|
||||
FollowTarget.localRotation = _initialTargetRotation * Quaternion.Euler(xOffset, yOffset, 0f);
|
||||
}
|
||||
_rotationOffset.rotationOffset = _initialTargetRotation + new Vector3(xOffset, yOffset, zOffset);
|
||||
}
|
||||
|
||||
public virtual void OnMMCinemachineRotationShakeEvent(MMF_Feedback source,
|
||||
|
||||
Reference in New Issue
Block a user