기존 코드에서 TMP Text를 사용하는 데 문제가 있었습니다. UI_Button 클래스에서 GetText 메서드를 호출하면서도 실제로는 Text 타입의 오브젝트가 반환되고 있었습니다. 이는 TMP Text를 사용하기 위해 수정이 필요한 부분입니다.
using System;
using System.Collections;
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
{
Imeage
}
private void Start()
{
Bind<Button>(typeof(Buttons));
Bind<Text>(typeof(Texts));
Bind<GameObject>(typeof(GameObjects));
Bind<Image>(typeof(Images));
GetText((int)Texts.ScoreText).text = "Bind Test";
GameObject go = GetImage((int)Images.Imeage).gameObject;
AddUIEvent(go, (PointerEventData data) => { go.transform.position = data.position; }, Define.UIEvent.Drag);
}
}
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using TMPro;
public class UI_Button : UI_Base
{
enum Buttons
{
PointButton
}
enum Texts
{
PointText,
ScoreText
}
enum GameObjects
{
//TestObject
}
enum Images
{
Image
}
private void Start()
{
Bind<Button>(typeof(Buttons));
Bind<TMP_Text>(typeof(Texts)); // TMP_Text로 변경
Bind<GameObject>(typeof(GameObjects));
Bind<Image>(typeof(Images));
GetText((int)Texts.ScoreText).text = "Bind Test";
GameObject go = GetImage((int)Images.Image).gameObject;
AddUIEvent(go, (PointerEventData data) => { go.transform.position = data.position; }, Define.UIEvent.Drag);
}
}
댓글 영역