8. 动画编辑
动画
属性列表
属性 | 属性名 | 类型 | 默认值/可选值 | 说明 |
启用 | enabled | bool | true、false | 是否开启动画组件 |
自动播放 | playAutomatically | bool | true、false | 是否自动播放动画 |
播放模式 | wrapMode | WrapMode | Default | 多种播放模式选择。Once,Loop,PingPong,Clamp |
默认动画 | defaultclipName | string | | 选择默认播放动画 |
示例代码
// 是否自动播放|playAutomatically
animation.playAutomatically = true;
// 选择播放模式|wrapMode
animation.wrapMode = WrapMode.Loop;
// 选择默认动画|defaultclipName
animation.defaultclipName = "Take";
示例案例
Animation_Demo() {
// 获取name为吊钩的三维物体
Actor animation_actor = Actor.Find("吊钩");
// 需要先为吊钩创建一个动画事件
// 获取动画组件
Animation animation = animation_actor.GetComponent<Animation>();
// 是否启用|enabled
animation.enabled = true;
// 是否自动播放|playAutomatically
animation.playAutomatically = true;
// 选择播放模式|wrapMode Clamp,Once,Loop,PingPong,ClampForever
animation.wrapMode = WrapMode.Loop;
// 选择默认动画|defaultclipName
animation.defaultclipName = "walk";
}