버튼과 인풋필드를 활용한 로그인 팝업을 구현하였다. 기능 구현은 단순하지만 오브젝트들을 배치하는 과정에서 UI 요소들을 가리거나 잘못 배치하는 것을 주의해야한다.

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;

public class UIPopupLogIn : MonoBehaviour
{
    public TMP_InputField idTxt;
    public TMP_InputField pwTxt;
    public Button[] arrBtns;
    
    

    void Start()
    {
        this.arrBtns[0].onClick.AddListener(() => 
        {
            this.LogInBtn();            
        });

        this.arrBtns[1].onClick.AddListener(() =>
        {
            this.ClothBtn();
        });
    }

    public void ClothBtn()
    {
        this.gameObject.SetActive(false);
    }

    public void LogInBtn()
    {
        string id = this.idTxt.text;
        string pw = this.pwTxt.text;

        Debug.LogFormat("ID:{0}\nPW:{1}", id, pw);
    }
}

+ Recent posts