티스토리 뷰

게임클라이언트 프로그래밍/Unity

UI Animation

Game Client Lee Hwanguk 2023. 2. 9. 15:21

#stage clear Scene의 UI들에 애니메이션을 적용해보았다

#1. Animator를 이용하여 효과 연출해보기

* star(left-mid-right) 순으로 등장하며 등장 하면 fx효과를 적용

*star가 모두 등장한다면 bust 효과 적용

# 2.스크립트로 애니메이션을 컨트롤해보자

*1.star하나하나(left,mid,right) 각각의 Animation을 생성하자

*2.스크립트를 통하여 일정한 delay를 갖고 실행되게만들어보자

*3.star가 모두 활성되면 Bust effect가 active된다

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TestAnim : MonoBehaviour
{
    public GameObject ribbon;
    public GameObject bg;
    public GameObject[] stars;
    public ParticleSystem fxStar;
    private float delay = 1f;
    private int cnt = 0;
    void Start()
    {
        this.ribbon.SetActive(true);
        this.bg.SetActive(true);
        this.fxStar.gameObject.SetActive(false);
        for (int i = 0; i < stars.Length; i++)
        {
            stars[i].SetActive(false);
        }
        StartCoroutine("WaitStars");       
    }
    private IEnumerator WaitStars()
    {       
        for(int i=0; i<stars.Length; i++)
        {
            stars[i].SetActive(true);
            Debug.Log("<color=yellow> Star! </color>");
            this.cnt++;
            Debug.Log(this.cnt);
            yield return new WaitForSeconds(delay);
            StartCoroutine("Bust");
        }
    }
    private IEnumerator Bust()
    {
        if (this.cnt == stars.Length)
        {
            this.fxStar.gameObject.SetActive(true);
            Debug.Log("<color=red>Bust!</color>");           
        }
        yield return new WaitForSeconds(1);

    }


}

 

 

 

'게임클라이언트 프로그래밍 > Unity' 카테고리의 다른 글

UI 연습(Login->Title)  (0) 2023.02.11
SpaceShooter  (1) 2023.02.10
Unity TabButton  (0) 2023.02.08
Unity Button  (0) 2023.02.08
Unity toggle  (1) 2023.02.07
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2025/07   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함