클릭한 버튼 오브젝트와 오브젝트 이름 가져오기
버튼을 클릭했을 때 , 해당 오브젝트의 이름에 따라서
동작하는 방법을 찾다가 클릭하는 오브젝트의 이름을 받아서
이름에 따라 조건을 주어서 이벤트를 발생하는 방법을 사용하게 되면서
다음과 같이 EventSystem.current.currentSelectedGameObject 를 사용해주었다.
using UnityEngine.EventSystems;
public class Button : MonoBehaviour
{
// 버튼 이름 가져오기
public void GetButtonName()
{
string EventButtonName = EventSystem.current.currentSelectedGameObject.name;
}
// 버튼 오브젝트 가져오기
public void GetButtonName()
{
GameObject EventButtonOb = EventSystem.current.currentSelectedGameObject;
}
}