-
04/22 UIAnimation R&D유니티 2021. 4. 22. 15:40
UI에 애니메이션을 추가하고 이펙트를 이벤트로 실행
코드
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class TestUIAnimation : MonoBehaviour { public Button btn; public Animator anim; public ParticleSystem[] arrEff; // Start is called before the first frame update void Start() { this.anim.GetComponent<UIAnimationReceiver>().onFinished = () => { //플레이 완료시 이펙트 실행 //Debug.LogError("finished"); foreach (var ps in this.arrEff) { ps.Play(); } }; this.anim.speed =0; this.anim.gameObject.SetActive(false); this.btn.onClick.AddListener(() => { this.anim.speed = 1; this.anim.gameObject.SetActive(true); this.anim.Play("test_star"); this.anim.Play("test_star", -1, 0f); }); } // Update is called once per frame void Update() { } }
using System.Collections; using System.Collections.Generic; using UnityEngine; public class UIAnimationReceiver : MonoBehaviour { // Start is called before the first frame update public System.Action onFinished; public void OnFinished() { if (this.onFinished != null) { this.onFinished(); } } }
'유니티' 카테고리의 다른 글
04/23 유니티 UI 스크롤 뷰 만들기 (0) 2021.04.23 04/22 유니티 UIAnimation (0) 2021.04.22 04/21 UI json데이터를 읽고 스테이지 정보 출력 (0) 2021.04.21 04/16 수업내용 메모 (0) 2021.04.16 04/15 유니티 애니메이션 컨트롤러 연습 (0) 2021.04.16