Yang.공부방

FadIn,FadOut 코드

Unity/과제2019. 4. 17. 01:54



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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
 
namespace yangjaejoon.scenes
{
    public class App : MonoBehaviour
    {
        public Camera uiCamera;
 
        private void Awake()
        {
            //인스턴스가 로딩될 때 Awake 실행
            Object.DontDestroyOnLoad(this);
        }
 
        // Start is called before the first frame update
        void Start()
        {
            var oper = SceneManager.LoadSceneAsync("Logo");
            oper.completed += (asyncOper) =>
            {
                var logo = GameObject.FindObjectOfType<Logo>();
                logo.uiLogo.Init(this.uiCamera);
                StartCoroutine(logo.uiLogo.FadeIn());
                logo.uiLogo.onFadeInCompleted = () =>
                 {
                     Debug.Log("FadeIn완료");
                     StartCoroutine(logo.uiLogo.WaitForSeconds(3));
                     logo.uiLogo.onWaitForCecondsCompleted = () =>
                     {
                         StartCoroutine(logo.uiLogo.FadeOut());
                         logo.uiLogo.onFadeOutCompleted = () =>
                         {
                             Debug.Log("FadOut완료");
                         };
                     };
                 };
 
            };
        }
 
        // Update is called once per frame
        void Update()
        {
 
        }
    }
}
cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace yangjaejoon.scenes
{
public class App : MonoBehaviour
{
public Camera uiCamera;
private void Awake()
{
//인스턴스가 로딩될 때
Object.DontDestroyOnLoad(this);
}
// Start is called before the first frame update
void Start()
{
var oper = SceneManager.LoadSceneAsync("Logo");
oper.completed += (asyncOper) =>
{
var logo = GameObject.FindObjectOfType<Logo>();
logo.uiLogo.Init(this.uiCamera);
StartCoroutine(logo.uiLogo.FadeIn());
logo.uiLogo.onFadeInCompleted = () =>
{
Debug.Log("FadeIn완료");
StartCoroutine(logo.uiLogo.WaitForSeconds(3));
logo.uiLogo.onWaitForCecondsCompleted = () =>
{
StartCoroutine(logo.uiLogo.FadeOut());
logo.uiLogo.onFadeOutCompleted = () =>
{
Debug.Log("FadOut완료");
};
};
};
};
}
// Update is called once per frame
void Update()
{
}
}
}

1
2
3
4
5
6
7
8
9
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class UILogo : UIBase
{
    
}
 
cs

1
2
3
4
5
6
7
8
9
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Logo : MonoBehaviour
{
    public UILogo uiLogo;
}
 
cs