인게임화면을 클릭했을때 프리펩화한 로그인창을 UIManager로 동적으로 불러온 다음 활성화 상태에서 버튼을 클릭했을 경우 텍스트를 출력하고 파괴하도록 하였다.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Test02UIManager : MonoBehaviour
{
[SerializeField]
private Test02InputField inputField;
[SerializeField]
private Button home;
// Start is called before the first frame update
void Start()
{
this.home.onClick.AddListener(() =>
{
Instantiate(inputField);
});
}
// Update is called once per frame
void Update()
{
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class Test02InputField : MonoBehaviour
{
[SerializeField]
private TMP_InputField input;
[SerializeField]
private Button buttonInactive;
[SerializeField]
private Button buttonActive;
// Start is called before the first frame update
void Start()
{
buttonActive.onClick.AddListener(() =>
{
Destroy(this.gameObject);
Debug.Log(this.input.text);
});
}
// Update is called once per frame
void Update()
{
if(input.text == "")
{
buttonInactive.gameObject.SetActive(true);
buttonActive.gameObject.SetActive(false);
}
else
{
buttonInactive.gameObject.SetActive(false);
buttonActive.gameObject.SetActive(true);
}
}
}
'유니티 심화' 카테고리의 다른 글
[UI] 스크롤뷰 (0) | 2023.09.07 |
---|---|
[UI] 스테이지 페이지 만들기 (0) | 2023.09.06 |
[UI] 슬롯에서 영웅 생성하기 + 데이터 연동 (0) | 2023.09.01 |
(수정중) 유니티 New Input System 사용하여 이동 구현 (0) | 2023.09.01 |
유니티 new Input System으로 조이스틱 사용하기 (0) | 2023.08.31 |