新Feedback系统
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using Sirenix.OdinInspector;
|
||||
using SLSUtilities.Feedback;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Cielonos.MainGame.Effects.Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Cinemachine Impulse 反馈,通过 CinemachineImpulseDefinition 直接创建脉冲事件。
|
||||
/// 需要场景中 Cinemachine Camera 上有 CinemachineImpulseListener 组件。
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class CinemachineImpulseAction : FeedbackActionBase
|
||||
{
|
||||
public override string DisplayName => "Cinemachine Impulse";
|
||||
|
||||
/// <summary>
|
||||
/// Impulse 定义,包含信号形状、衰减模式、持续时间等。
|
||||
/// </summary>
|
||||
[Title("Impulse Settings")]
|
||||
public CinemachineImpulseDefinition impulseDefinition = new CinemachineImpulseDefinition();
|
||||
|
||||
/// <summary>
|
||||
/// 脉冲速度向量。
|
||||
/// </summary>
|
||||
[LabelText("Velocity")]
|
||||
public Vector3 velocity = new Vector3(5f, 5f, 5f);
|
||||
|
||||
/// <summary>
|
||||
/// Stop 时是否清除所有 impulse。
|
||||
/// </summary>
|
||||
[LabelText("Clear Impulse on Stop")]
|
||||
public bool clearImpulseOnStop;
|
||||
|
||||
/// <summary>
|
||||
/// 方向影响设置。
|
||||
/// </summary>
|
||||
[Title("Direction")]
|
||||
public CameraDirectionSettings directionSettings = new CameraDirectionSettings();
|
||||
|
||||
public override void OnStart(FeedbackContext context)
|
||||
{
|
||||
Vector3 finalVelocity = directionSettings.TransformAmplitude(velocity, context.owner);
|
||||
Vector3 position = context.owner != null ? context.owner.position : Vector3.zero;
|
||||
|
||||
CinemachineImpulseManager.Instance.IgnoreTimeScale = true;
|
||||
impulseDefinition.CreateEvent(position, finalVelocity);
|
||||
}
|
||||
|
||||
public override void OnInterrupt(FeedbackContext context)
|
||||
{
|
||||
if (clearImpulseOnStop)
|
||||
{
|
||||
CinemachineImpulseManager.Instance.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user