using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SimpleAnimationPlayer : MonoBehaviour
{
public Animation ani;
public string clip_name;
public float ani_time;
private void Update()
{
if (Input.GetKeyDown("1"))
{
Show();
}
if (Input.GetKeyDown("2"))
{
Hide();
}
}
public void Hide()
{
if (ani_time == ani[clip_name].length)
return;
ani_time = ani[clip_name].time;
func_playAni(ani_time, clip_name);
}
public void Show()
{
if (ani_time == 0)
ani_time = ani[clip_name].length;
else
ani_time = ani[clip_name].time;
func_reversPlay(ani_time, clip_name);
}
public void func_playAni(float time, string aniName)
{
ani[aniName].time = time;
ani[aniName].speed = 1;
ani.Play();
}
public void func_reversPlay(float time, string aniName)
{
ani[aniName].time = time;
ani[aniName].speed = -1;
ani.Play();
}
}
댓글 없음:
댓글 쓰기