버튼과 인풋필드를 활용한 로그인 팝업을 구현하였다. 기능 구현은 단순하지만 오브젝트들을 배치하는 과정에서 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);
}
}
'C# > 수업 과제' 카테고리의 다른 글
이진트리 구현과 순회 (0) | 2023.02.09 |
---|---|
재귀함수를 통한 팩토리얼, 피보나치수열 구현 (0) | 2023.02.08 |
Unity) [유니티 UI] 체크박스 만들기 (0) | 2023.02.07 |
Unity) 유니티 Button.onClick.AddListener 람다식 주의점 (0) | 2023.02.07 |
오브젝트 풀링 (0) | 2023.02.05 |