본문 바로가기

Unity/수업내용

2020-05-22 수업내용 로그인 화면 만들기

 

Login.class

더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class Login : MonoBehaviour
{
    public UILogin uILogin;
 
    //테스트
    private void Start()
    {
        this.Init();
    }
    public void Init()
    {
        this.uILogin.Init();
    }
    
}
 
 
 

 

UILogin.class

더보기
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class UILogin : UIBase
{
    public Button btn;
    public UIPopup_Login uiPopupLogin;
 
    public override void Init(UIBaseParam param = null)
    {
       
        //어디서 보이고 사라질지 한군데에다가 몰아놓음.
        //이렇게해야 관리도 편하고, 코드가 분리가 안됨.
        //코드분리가 안되는게 중요
 
        //var param = new UIPopup_Login.UIPopup_LoginParam(1);
        //this.uiPopupLogin.Init(param);
 
        this.uiPopupLogin.btnClose.onClick.AddListener(()=> {
            Debug.Log("close");
            this.uiPopupLogin.Hide();
        });
 
        this.btn.onClick.AddListener(() => {
            Debug.Log("open");
            this.uiPopupLogin.Show();
        });
    }
}
 
 
 

 

UIPopup_Login.class

더보기
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
 
public class UIPopup_Login : UIPopupBase
{
    
    public class UIPopup_LoginParam : UIBaseParam //클래스 안에 상속클래스
    {
        public int Id { get; private set; }
        public UIPopup_LoginParam(int id)
        {
            //생성자
            this.Id = id;
        }
 
    }
 
    public Button btnSign;
    public Button btnClose;
    public Button btnLogin;
 
    public override void Init(UIBaseParam param = null)
    {
 
        //이부분을 읽을 줄 알아야..
 
        /*
        var loginParam = (UIPopup_LoginParam)param;
 
        Debug.LogFormat("id: {0}", loginParam.Id);
 
        base.Init(param);
        */
 
        //위와 처리내용이 같으나, 구조가 다른것
 
        base.Init(param);
 
        var loginParam = (UIPopup_LoginParam)this.param;
 
        Debug.LogFormat("id: {0}", loginParam.Id);
 
    }
 
    private void Start()
    {
        this.btnSign.onClick.AddListener(() =>
        {
            Debug.Log("가입하실라우");
        });
 
        this.btnLogin.onClick.AddListener(() =>
        {
            Debug.Log("로그인");
            SceneManager.LoadScene("Lobby");
 
        });
    }
 
    public override void Show()
    {
        //UIPopup_Login의 따로 구현
 
        base.Show();
    }
 
    public override void Hide()
    {
        //UIPopup_Login의 따로 구현
 
        base.Hide();
    }
 
    private void Update()
    {
 
    }
}