欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Animation组件的属性和方法介绍

程序员文章站 2022-03-16 16:48:52
...
        // Animation
        animation.AddClip(new AnimationClip(), "NewAnimName");
        animation.AddClip(new AnimationClip(), "NewAnimName", 1/*首帧*/, 2/*尾帧*/);
        animation.AddClip(new AnimationClip(), "NewAnimName", 1, 2, true/*是否应该在最后插入一个额外的帧匹配第一帧?如果你在制作一个循环的动画,那么可以打开这个选项*/);
        animation.clip = null;  // 默认动画
        // 淡入淡出
        animation.CrossFade("AnimName");
        animation.CrossFade("AnimName", 1f/*混合时长*/);
        animation.CrossFade("AnimName", 1f, PlayMode.StopAll/*立即开始播放重复的动画状态*/);
        animation.CrossFade("AnimName", 1f, PlayMode.StopSameLayer/*停止相同动画层级的动画*/);
        animation.CrossFadeQueued("AnimName");
        animation.CrossFadeQueued("AnimName", 1f/*混合时长*/);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.CompleteOthers/*等待其它动画停止后淡入淡出*/);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.CompleteOthers, PlayMode.StopAll/*立即开始播放重复的动画状态*/);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.CompleteOthers, PlayMode.StopSameLayer/*停止相同动画层级的动画*/);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.PlayNow/*立即开始播放重复的动画状态*/);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.PlayNow, PlayMode.StopAll);
        animation.CrossFadeQueued("AnimName", 1f, QueueMode.PlayNow, PlayMode.StopSameLayer);
        animation.cullingType = AnimationCullingType.AlwaysAnimate; // 不管在不在视窗内都播放
        animation.cullingType = AnimationCullingType.BasedOnRenderers;  // 只在渲染该物体时才播放
        animation.enabled = false;
        animation.GetClip("AnimName");
        animation.GetClipCount();
        animation.IsPlaying("AnimName");
        bool bIsPlaying = animation.isPlaying;
        Bounds bounds = animation.localBounds;
        animation.Play(PlayMode.StopAll/*停止其它*/);   // 播放默认动画
        animation.Play(PlayMode.StopSameLayer/*停止相同动画层级的动画*/);  // 播放默认动画
        animation.Play("AnimName");
        animation.Play("AnimName", PlayMode.StopAll/*停止其它*/);
        animation.Play("AnimName", PlayMode.StopSameLayer/*停止相同动画层级的动画*/);
        animation.playAutomatically = false;    // 是否应该在启动时自动开始播放
        animation.PlayQueued("AnimName");
        animation.PlayQueued("AnimName", QueueMode.CompleteOthers/*等待其它动画停止后淡入淡出*/);
        animation.PlayQueued("AnimName", QueueMode.PlayNow/*等待其它动画停止后立即开始播放*/);
        animation.RemoveClip("AnimName");
        animation.Rewind(); // 倒播所有动画
        animation.Rewind("AnimName");   // 倒播名为name的动画
        animation.SyncLayer(1); // 同步某层中所有动画的播放速度
        // 如何处理超出剪辑播放范围的时间
        animation.wrapMode = WrapMode.Clamp;/*停在尾帧*/
        animation.wrapMode = WrapMode.ClampForever/*停在尾帧并保持播放*/;
        animation.wrapMode = WrapMode.Default/*从动画剪辑中读取循环模式(默认是Once)*/;
        animation.wrapMode = WrapMode.Loop/*循环播放*/;
        animation.wrapMode = WrapMode.Once/*播完停止*/;
        animation.wrapMode = WrapMode.PingPong/*往复式循环播放*/;
        AnimationState MyAnimationState = animation["AnimName"];
        AnimationClip MyAnimationClip = animationState.clip;
        AnimationClip MyAnimationClip2 = animation.GetClip("AnimName");
        animationState.AddMixingTransform(transform);   // 给某个节点及其子节点播放动画 animation["wave_hand"].AddMixingTransform(transform.Find("root/upper_body/left_shoulder"));
        animationState.AddMixingTransform(transform, true/*是否影响子节点*/);
        animationState.RemoveMixingTransform(transform);
        animationState.blendMode = AnimationBlendMode.Additive; // 叠加混合
        animationState.blendMode = AnimationBlendMode.Blend;    // 混合
        animationState.enabled = false;
        animationState.layer = 1;   // 动画层级高代表权重高
        float fLength = animationState.length;  // 时长(秒)
        animationState.name = "AnimStateName";
        animationState.normalizedSpeed = 1f;    // 同步播放速度 请用SyncLayer代替
        animationState.normalizedTime = 1f; // 把时间标准化为0f ~ 1f
        animationState.speed = 1f;
        animationState.time = 1f;   // 当前时间
        animationState.weight = 1f; // 权重
        // 结束方式
        animationState.wrapMode = WrapMode.Clamp;/*停在尾帧*/
        animationState.wrapMode = WrapMode.ClampForever;/*停在尾帧并保持播放*/
        animationState.wrapMode = WrapMode.Default;/*从动画剪辑中读取循环模式(默认是Once)*/
        animationState.wrapMode = WrapMode.Loop;/*循环播放*/
        animationState.wrapMode = WrapMode.Once;/*播完停止*/
        animationState.wrapMode = WrapMode.PingPong;/*往复式循环播放*/