Files
aibis-dream/Assets/Scripts/MiniGame/HuoShan/EmotionWave/README_SliderSync.md
T
2026-02-25 16:19:28 +08:00

95 lines
2.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# EmotionWave 与 SliderController 同步使用说明
## 概述
`EmotionWaveManager` 可以自动同步 `SliderController` 的进度,实现滑片位置驱动情绪波形进度的效果。
## 设置方法
### 1. Inspector 配置
`EmotionWaveManager` 组件的 Inspector 中:
```
[Header("Slider Sync")]
- Slider Controller: 拖入场景中的 SliderController 组件
- Enable Slider Sync: 勾选启用滑片同步(默认启用)
```
### 2. 工作原理
`Enable Slider Sync` 勾选时:
- `SliderController``onSliderPositionChanged` 事件会自动触发
- `EmotionWaveManager` 接收到事件后更新 `targetProgress`
- `Update` 中的 smoothstep lerp 会平滑追踪到新进度
- 最终传递给 `EmotionWaveController` 进行渲染
### 3. Yarn 脚本控制
#### 启用/禁用同步
```yarn
// 启用滑片同步(情绪波形跟随滑片)
<<enable_emotion_wave_slider_sync>>
// 禁用滑片同步(情绪波形由 Yarn 命令独立控制)
<<disable_emotion_wave_slider_sync>>
```
#### 典型使用场景
```yarn
// 场景1: 显示情绪波形,同时启用滑片同步
<<show_emotion_wave>>
<<enable_emotion_wave_slider_sync>>
// 玩家操作滑片时,情绪波形自动跟随
// ...
// 场景2: 禁用同步,手动控制进度
<<disable_emotion_wave_slider_sync>>
<<emotion_wave_to 0.5 2>> // 2秒动画到进度0.5
// 场景3: 立即设置进度(跳过动画)
<<set_emotion_wave 0.75>>
```
## 事件流程
```
SliderController.SlideToNormalized(0.5f)
SliderController._currentAngle 更新
SliderController.onSliderPositionChanged.Invoke(0.5f)
EmotionWaveManager.OnSliderPositionChanged(0.5f)
EmotionWaveManager.targetProgress = 0.5f
EmotionWaveManager.Update() - smoothstep lerp 追踪
EmotionWaveManager.currentProgress 平滑到 0.5f
EmotionWaveController.Progress = currentProgress
EmotionWaveRenderer 渲染对应阶段的波形
```
## 注意事项
1. **优先级**:当滑片同步启用时,Yarn 命令的 `emotion_wave_to``set_emotion_wave` 仍然有效,但会与滑片进度产生竞争。建议:
- 滑片控制时:启用同步
- Yarn 自动演出时:禁用同步
2. **平滑追踪**:无论进度来源(滑片/Yarn),都会经过 smoothstep lerp 平滑处理(lerpSpeed = 4.0
3. **性能**:事件机制确保只在滑片位置实际改变时触发,不会每帧都更新
## 调试
在 Inspector 的 Debug 区域可以实时查看:
- `Current Progress`:当前平滑后的进度
- `Target Progress`:目标进度(来自滑片或 Yarn
- `Is Shown`:是否显示状态