通过动画可以使用 Unity 的动画系统完全动画化控件状态之间的每个过渡。由于可以同时动画化的属性数量很多,因此这是最强大的过渡模式。
要使用动画过渡模式,必须将动画器组件附加到控制器元素。通过单击“Auto Generate Animation”即可自动完成此操作。此过程也会生成一个已经设置状态的动画控制器,并需要对此进行保存。
新的动画控制器可以立即使用。与大多数动画控制器不同,此控制器还会存储控制器过渡的动画,如果需要,还可以进行自定义。
例如,如果选择附加了动画控制器的按钮元素,则可以通过打开 Animation 窗口 (Window>Animation) 来编辑每个按钮状态的动画。
有一个 Animation Clip 弹出菜单可以选择所需的剪辑。选项包括“Normal”、“Highlighted”、“Pressed”和“Disabled”。
Normal 状态由按钮元素本身上的值设置,并可保留为空。在所有其他状态中,最常见的配置是时间轴开头的单个关键帧。状态之间的过渡动画将由动画器处理。
例如,可从 Animation Clip 弹出菜单中选择 Highlighted 状态并将播放头置于时间轴的开头来更改 Highlighted 状态按钮的宽度:
切换到播放模式以查看按钮突出显示时的变化情况。
任何数量的属性都可以在这一个关键帧中设置其参数。
通过共享动画控制器,多个按钮可共享相同的行为。
UI 动画过渡模式与 Unity 的旧版动画系统不兼容。仅应使用动画器组件。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.