Image를 마우스로 드래그할 수 있는 이벤트를 구현하기 위해 UI EventHandler 추가
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UI_Button : UI_Base
|
||||
@@ -22,6 +23,11 @@ public class UI_Button : UI_Base
|
||||
TestObject
|
||||
}
|
||||
|
||||
enum Images
|
||||
{
|
||||
ItemIcon,
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Reflection
|
||||
@@ -29,10 +35,15 @@ public class UI_Button : UI_Base
|
||||
// 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;
|
||||
|
||||
Reference in New Issue
Block a user