| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using UnityEngine;
- namespace UnityCommon
- {
- public class AnimState : CameraState
- {
- public Transform tfCameraAnim;
- private Animation animation;
- public AnimState(Camera camera, AnimationClip animClip) : base(camera)
- {
- animation = m_camera.gameObject.AddComponentOnlyOne<Animation>();
- animation.clip = animClip;
- }
- public override void Enter()
- {
- base.Enter();
- animation.enabled = true;
- tfCameraAnim.SetParent(null);
- tfCameraAnim.gameObject.SetActive(true);
- PlayAnim();
- }
- public override void Exit()
- {
- base.Exit();
- StopAnim();
- animation.enabled = false;
- }
- public void PlayAnim()
- {
- animation.Play();
- }
- public void StopAnim()
- {
- animation.Stop();
- }
- }
- }
|