Fader를 사용하려고 했는데 이게 불가능하더라...

유니티 도큐먼트에 보면 guiTexture로 작성되어 있기 때문(유니티 4.2버전 기준이라고 써있음)

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
51
52
53
 
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
 
public class Fade : MonoBehaviour
{
    public Image Black_screen;
    public float Fade_Time = 2f;
    public float Fade_Max = 1f;
    float _time;
    public bool FadeIn_ing = true;
    public bool FadeOut_ing;
 
    void Start ()
    {
 
    }
 
    void Update ()
    {
        if (FadeIn_ing) {
            _time += Time.deltaTime;
            Black_screen.color = Color.Lerp (new Color (000, Fade_Max), new Color (0000), _time / Fade_Time);
        }
 
        if (FadeOut_ing) {
            _time += Time.deltaTime;
            Black_screen.color = Color.Lerp (new Color (0000), new Color (000, Fade_Max), _time / Fade_Time);
        }
 
        if (_time >= Fade_Time) {
            _time = 0;
            
            FadeOut_ing = false;
            
            if(FadeIn_ing==true){
                Destroy(this.gameObject);    
            }
            
        }
    }
 
    public void FadeIn ()
    {
        FadeIn_ing = true;
    }
 
    public void FadeOut ()
    {
        FadeOut_ing = true;
    }
}
cs

검정색 큰 화면을 준비 

guitexture대신에 받을 Image를 불러와

color로 접근하면 fader를 사용할 수 있음 

'Unity' 카테고리의 다른 글

Unity5 Collider  (0) 2015.03.05
Unity5 audio 접근법  (0) 2015.03.04
unity5 업데이트시 UnityVS 연결하는 방법  (0) 2015.03.04
Ray로 무너뜨리는 느낌 주기?  (0) 2014.08.14
NGUI 3.6.x버전 버튼 클릭 이벤트 만들기  (0) 2014.08.02

+ Recent posts