Unity old animation system Animation

1. Create an old animation system

Add the Animation component to the GameObeject to be animated

2. Animation parameters

Animation: The animation played by default
Animations: All animations that this animation component can control
Play AutoMatically: Whether the default animation is automatically played at the beginning
Animate Physics: Whether the animation interacts with physics
Culling Type: Decide when not to play the animation
    Always Animate: Always play
    Based On Renderers: Culling based on default animation pose

3. Old animation file parameters

Default: Read the default repeat mode set higher
Once: Play once and stop
Loop: Play continuously from beginning to
end PingPong: Play continuously from beginning to end
ClampForever: The end of playback will stop at the last frame, and The last frame will always be played (equivalent to the status of not stopping). The performance effect is the same as Once, but the logic processing is different.

4. Code control animation

        Animation animation = this.gameObject.GetComponent<Animation>();

        //播放动画
        animation.Play("OldAnimation");

        //淡入播放
        animation.CrossFade("OldAnimation2");

        //播放完前一个动画再播放下一个
        animation.PlayQueued("OldAnimation2");
        animation.CrossFadeQueued("OldAnimation2");

        //停止所有动画
        animation.Stop();

        //是否在播放某个动画
        animation.IsPlaying("OldAnimation");

        //播放模式设置
        animation.wrapMode = WrapMode.Default;

5. Animation events

Define event function

    public void AnimationEvent()
    {
        print("OK");
    }

Click the event of the Animation window (blue mark)

Add a function in the Inspector window

 

 

Guess you like

Origin blog.csdn.net/holens01/article/details/130929999