Files
aibis-dream/Docs/HuoShan/SaleView_EnterAnimation_Setup.md

81 lines
3.1 KiB
Markdown
Raw Permalink 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.
# SaleView 进入动画配置指南
## 一、层级结构说明
SaleViewSellView)下主要结构:
```
SellView
└── 步进模式
├── 轨道底座A ~ 轨道底座H (轨道底座组,共 8 个)
├── 内环
├── 外边框
├── 滑片c (滑片,需切换帧 a/b/c)
├── 电夹 (夹片,需 fadein
└── 其他(发条、线圈等)
```
## 二、实现方式:AnimClip + Animator Controller
### 1. 创建 Animator 与脚本
1.`步进模式` GameObject 上添加 `Animator` 组件(若无)
2. 添加 `SaleViewEnterAnimation` 脚本
3. 将步进模式设为默认**初始状态**(缩起、夹片透明等)
### 2. 创建 Animation ClipSaleViewEnter.anim
`Assets/Animation/HuoShan/` 下创建 `SaleViewEnter.anim`,绑定到 `步进模式`,添加如下曲线:
| 目标路径 | 属性 | 初始(0s) | 结束(0.6s) | 说明 |
|----------|------|----------|-------------|------|
| 轨道底座A ~ H | Transform.localScale | (0.3,0.3,1) | (1,1,1) | 轨道底座伸张 |
| 内环 | Transform.localScale | (0.5,0.5,1) | (1,1,1) | 内环放大 |
| 外边框 | Transform.localScale | (0.5,0.5,1) | (1,1,1) | 外边框放大 |
| 滑片c | SpriteRenderer.sprite | 滑片c 的 Sprite | 滑片a 的 Sprite | 帧切换 c→b→a |
| 电夹 | SpriteRenderer.color.a | 0 | 1 | 夹片淡入 |
**滑片帧动画**:在 0s 使用滑片c Sprite0.3s 使用滑片b0.6s 使用滑片a(若资源有 a、b、c 三帧)。
### 3. 创建 Animator ControllerSaleViewEnter.controller
1. 创建 `SaleViewEnter.controller`
2. 添加 **Bool** 参数:`Enter`(或 **Trigger**`Enter`
3. 添加两个状态:
- **Idle**:默认状态,绑定一帧保持“缩起”的 clip(或空 clip)
- **Enter**:绑定 `SaleViewEnter.anim`
4. 默认状态设为 **Idle**
5. 添加 Transition`Entry → Idle``Idle → Enter` 条件为 `Enter` Trigger`Enter → Idle` 勾选 “Has Exit Time”
### 4. 挂接到 SalesManager
1.`SaleViewEnter.controller` 赋给 `步进模式` 的 Animator
2.`SaleViewEnterAnimation``animatorController` 中引用该 Controller(可选,脚本会使用 Animator 上已有的)
3. `SalesManager.OpenView()` 会自动调用 `SaleViewEnterAnimation.PlayEnterAnimation()`
## 三、轨道底座组的两种做法
**方式 A:分别动画 8 个轨道底座**
每个 `轨道底座A` ~ `轨道底座H` 各做一条 `localScale` 曲线,从 (0.3,0.3,1) 到 (1,1,1)。
**方式 B:建父节点统一缩放**
1. 创建空 GameObject `轨道底座组`
2. 将 轨道底座A~H 拖为其子对象
3. 只对 `轨道底座组``localScale` 动画
## 四、夹片(电夹)淡入
- 使用 `SpriteRenderer.color` 的 alpha 通道
- 0salpha=0(透明)
- 0.6salpha=1(不透明)
若夹片有多个(如电阻圈、线圈等),可分别做 alpha 曲线。
## 五、默认保持初始状态
- Animator 默认进入 **Idle** 状态
- `SaleViewEnterAnimation.OnEnable()` 会执行 `Rebind()`,确保每次显示时从缩起状态开始
- 进入销售系统时调用 `PlayEnterAnimation()` 播放进入动画