c# 강의/유니티

20200507 - 애니메이션

쪼혀 2020. 5. 7. 12:43
using UnityEngine.UI; // 버튼 사용하려면  2019.3.7

public class App : MonoBehaviour
{
    public GameObject model; //구멍을 뚫어
    public Button btn; // 버튼 인스턴스

 

> 버튼 클릭시 리스너

 this.btn.onClick.AddListener(메소드());
        this.btn.onClick.AddListener(() =>
        {
            Debug.Log("test1");
        });

> 프레임 시간

timer += Time.deltaTime;

 

> 애니메이션 컴포넌트 먼저가져와야함(model은 GameObaect)

  var anim = this.model.GetComponent<Animation>(); // 애니 컴포넌트 가져와

 

> 애니메이션

var state = anim["attack_sword_01"]; // 애니메이션 컴포넌트 활용

 anim.Play("attack_sword_01"); //애니메이션 실행