58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class UI_Button : UI_Base
|
|
{
|
|
enum Buttons
|
|
{
|
|
PointButton,
|
|
}
|
|
|
|
enum Texts
|
|
{
|
|
PointText,
|
|
ScoreText,
|
|
}
|
|
|
|
enum GameObjects
|
|
{
|
|
TestObject
|
|
}
|
|
|
|
enum Images
|
|
{
|
|
ItemIcon,
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
// Reflection
|
|
Bind<Button>(typeof(Buttons));
|
|
// Text 대신 TextMeshProUGUI로 변경
|
|
Bind<TextMeshProUGUI>(typeof(Texts));
|
|
Bind<GameObject>(typeof(GameObjects));
|
|
Bind<Image>(typeof(Images));
|
|
|
|
// Get 호출 시에도 타입을 맞춰줍니다.
|
|
// Get<TextMeshProUGUI>((int)Texts.ScoreText).text = "Bind Test";
|
|
GetText((int)Texts.ScoreText).text = "Bind Test";
|
|
|
|
GameObject go = GetImage((int)Images.ItemIcon).gameObject;
|
|
UI_EventHandler evt = go.GetComponent<UI_EventHandler>();
|
|
evt.OnDragHandler += ((PointerEventData data) => { evt.gameObject.transform.position = data.position; });
|
|
}
|
|
|
|
private int _score = 0;
|
|
|
|
public void OnButtonClicked()
|
|
{
|
|
// GetComponentInChildren<TextMeshProUGUI>().text = "텍스트 변경 완료!";
|
|
|
|
_score += 1;
|
|
}
|
|
}
|