csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Test_FadeInMain : MonoBehaviour
{
[SerializeField]
private Image dim;
private System.Action onFadeInComplete;
// Start is called before the first frame update
void Start()
{
this.onFadeInComplete = () => {
//영웅추가
};
this.StartCoroutine(this.FadeIn());
}
private IEnumerator FadeIn()
{
Color color = this.dim.color;
//어두워져야함
while (true)
{
color.a -= 0.01f;
this.dim.color = color;
Debug.Log(this.dim.color.a);
if (this.dim.color.a <= 0)
{
break;
}
yield return null;
}
this.onFadeInComplete();
}
}
csharp
닫기using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Test_FadeOutMain : MonoBehaviour
{
[SerializeField]
private Image dim;
private System.Action onFadeOutComplete;
// Start is called before the first frame update
void Start()
{
this.onFadeOutComplete = () => {
//씬전환
SceneManager.LoadScene("Test_FadeIn");
};
this.StartCoroutine(this.FadeOut());
}
private IEnumerator FadeOut()
{
Color color = this.dim.color;
//어두워져야함
while(true)
{
color.a += 0.01f;
this.dim.color = color;
Debug.Log(this.dim.color.a);
if(this.dim.color.a >= 1)
{
break;
}
yield return null;
}
this.onFadeOutComplete();
}
}

'유니티 기초' 카테고리의 다른 글
[주말과제] 복소수와 사원수 (1) | 2023.08.14 |
---|---|
[합치기] 이동, 공격, 피격 (0) | 2023.08.11 |
무기, 방패 장착, 제거 - 생성 시 부모를 지정, 생성 후 부모를 지정 (0) | 2023.08.11 |
몬스터 2초 후 삭제, 아이템 드랍, 아이템 씬에서 제거 후 아이템 로그 출력 (0) | 2023.08.10 |
몬스터를 죽이면 리스트에서 없애고 임의 위치에 포탈생성 (0) | 2023.08.10 |