Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Animation.CrossFade 淡入淡出
# [Animation](Animation.html).CrossFade 淡入淡出 function *CrossFade* (*animation* : string, *fadeLength* : float = 0.3F, *mode* : [PlayMode](../Enumerations/PlayMode/PlayMode.html) = [PlayMode.StopSameLayer](../Enumerations/PlayMode/PlayMode.StopSameLayer.html)) : void *Description* 描述 Fades the animation with name animation in over a period of time seconds and fades other animations out. 在一定时间内淡入名称为 name 的动画并且淡出其他动画。 if mode is PlayMode.StopSameLayer, animations in the same layer as animation will be faded out while animation is faded in. if mode is PlayMode.StopAll, all animations will be faded out while animation is faded in. 如果模式是 PlayMode.StopSameLayer,在同一层的动画将在动画淡入的时候淡出。如果模式是 PlayMode.StopAll,所有动画将在淡入的时候淡出。 If the animation is not set to be looping it will be stopped and rewinded after playing. 如果动画没有被设置成循环,它将停止并且在播放完成之后倒带至开始。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public void Awake() { animation.CrossFade("Walk", 0.2F); } } ``` ``` // Fade the walk cycle in and fade all other animations in the same layer out. // 淡入walk循环并且淡出同一层的所有其他动画。 // Complete the fade within 0.2 seconds. // 在0.2秒之内完成淡入淡出。 animation.CrossFade("Walk", 0.2); ``` 另一个例子: * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Update() { if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1F) animation.CrossFade("Run"); else animation.CrossFade("Idle"); } } ``` ``` // Makes a character contains a Run and Idle animation // fade between them when the player wants to move // 让一个角色包含Run和Idle动画,并且在玩家想移动的时候在他们之间淡入淡出。 function Update () { if (Mathf.Abs(Input.GetAxis("Vertical")) > 0.1) animation.CrossFade("Run"); else animation.CrossFade("Idle"); } ```
da
2022年5月13日 22:06
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码