반응형
- 코드 작성 (Dotween 사용)
using UnityEngine;
using System.Collections;
using DG.Tweening;
public class WindowAnimation : MonoBehaviour
{
float duration = 0.15f;
Vector3 scaleTo = new Vector3(1f, 1f, 1f);
void OnEnable()
{
transform.localScale = new Vector3(0, 0, 0);
transform.DOScale(scaleTo, duration);
}
void OnDisable()
{
transform.localScale = new Vector3(0, 0, 0);
}
}
- 코드 작성
using UnityEngine;
using System.Collections;
public class WindowAnimation : MonoBehaviour
{
[Range(0, 0.5f)]
public float speed = 0.1f;
float size = 0;
void OnEnable()
{
size = 0;
transform.localScale = Vector3.zero;
StopAllCoroutines();
StartCoroutine(SizeCoroution());
}
IEnumerator SizeCoroution()
{
if (size < 1)
{
size += speed;
}
else
{
yield break;
}
transform.localScale = Vector3.one * size;
yield return new WaitForSeconds(0.01f);
StartCoroutine(SizeCoroution());
}
}
반응형
'개발 > C#' 카테고리의 다른 글
유니티 C# 랜덤 난수 생성 Random.Range 간단 사용법 (0) | 2022.06.21 |
---|---|
유니티 C# 특수문자 제한 간단 사용법 input text (0) | 2022.06.21 |
유니티 C# 캐릭터 키보드 이동 간단 구현 (0) | 2022.06.20 |
유니티 C# 키보드 입력 Keyboard input 간단 사용법 (0) | 2022.06.20 |
유니티 C# CSV 파일 저장, 불러오기 Read, Write 간단 사용법 (1) | 2022.06.20 |
유니티 C# 인앱결제 시스템 IAP Manager 간단 사용법 (0) | 2022.06.19 |
유니티 C# 인터넷 연결 상태 확인 Network Connect 간단 사용법 (0) | 2022.06.19 |
유니티 C# 기즈모 Gizmo 간단 사용법 (0) | 2022.06.19 |
댓글