UI 자동화를 위해 바인딩 기능 구현
- 유니티 에셋 인증 오류로 meta 재생성
This commit is contained in:
46
Assets/Scripts/UI/UI_Button.cs
Normal file
46
Assets/Scripts/UI/UI_Button.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UI_Button : UI_Base
|
||||
{
|
||||
enum Buttons
|
||||
{
|
||||
PointButton,
|
||||
}
|
||||
|
||||
enum Texts
|
||||
{
|
||||
PointText,
|
||||
ScoreText,
|
||||
}
|
||||
|
||||
enum GameObjects
|
||||
{
|
||||
TestObject
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Reflection
|
||||
Bind<Button>(typeof(Buttons));
|
||||
// Text 대신 TextMeshProUGUI로 변경
|
||||
Bind<TextMeshProUGUI>(typeof(Texts));
|
||||
Bind<GameObject>(typeof(GameObjects));
|
||||
|
||||
// Get 호출 시에도 타입을 맞춰줍니다.
|
||||
// Get<TextMeshProUGUI>((int)Texts.ScoreText).text = "Bind Test";
|
||||
GetText((int)Texts.ScoreText).text = "Bind Test";
|
||||
}
|
||||
|
||||
private int _score = 0;
|
||||
|
||||
public void OnButtonClicked()
|
||||
{
|
||||
// GetComponentInChildren<TextMeshProUGUI>().text = "텍스트 변경 완료!";
|
||||
|
||||
_score += 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user