public class ClickDoor : MonoBehaviour
{
public Animation _animation;
private bool state = false;
private AnimationState animationState;
private void Start()
{
_animation = GetComponent<Animation>();
foreach (AnimationState state in _animation)
{
animationState = state;
}
}
public void PlayDoorAnimation()
{
if (!state)
{
_animation.Play();
}
else
{
animationState.time = 0;
_animation.Sample();
_animation.Stop();
}
state = !state;
}
void OnMouseDown()
{
PlayDoorAnimation();
}
}
image.gif
网友评论