-
04/26 유니티 입력값 출력 복습 NGUI, UGUI유니티 2021. 4. 27. 01:58
NGUI를 배우기 시작
복습을 겸하여 NGUI와UGUI로 간단히 Input Field에 값을 입력하고, 버튼을 눌러 디버그 로그로 입력값을 출력하는 씬 제작
개인적 사용 느낌
UGUI를 먼저 배웠기 때문에 UGUI로 구현하는 편이 아직까지는 더 좋은 것 같음
NGUI의 특징
버튼이나 인풋필드같은 클릭이 필요한 것들에는 Collider 컴포넌트를 추가함
UGUI의 Order in Layer를 조절하는 것을 NGUI에서는 Sprite의 Widget의 Depth를 조절
UGUI
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class UGUILogin : MonoBehaviour { public Button btnLogin; public Text txtLogin; // Start is called before the first frame update void Start() { btnLogin.onClick.AddListener(() => { Debug.Log(txtLogin.text); }); } // Update is called once per frame void Update() { } }
NGUI
using System.Collections; using System.Collections.Generic; using UnityEngine; public class NGUILogin : MonoBehaviour { public UIButton btnLogin; public UILabel txtId; // Start is called before the first frame update void Start() { btnLogin.onClick.Add(new EventDelegate(() => { Debug.Log(txtId.text); })); } // Update is called once per frame void Update() { } }
'유니티' 카테고리의 다른 글
04/29 유니티 Hero Adventure 컨트롤 시스템 구현 (0) 2021.04.29 04/29 유니티 케릭터 컨트롤 + 인풋 R&D (0) 2021.04.29 04/26 유니티 NGUI slider 사용 연습 (0) 2021.04.26 04/26 유니티 NGUI 버튼, 입력창 연습 (0) 2021.04.26 04/23 유니티 스크롤 뷰 + 데이터 연동 연습 (0) 2021.04.23