본문 바로가기
소프트웨어 개발/유니티(Unity)

[Unity] 클릭한 오브젝트(버튼)의 이름 가져오기

by Sakriun_to 2021. 11. 30.
728x90
using UnityEngine.EventSystems;

public class ButtonController : MonoBehaviour
{
	public void GetButtonName(){
		// 버튼 이름 가져오기
		string ButtonName = EventSystem.current.currentSelectedGameObject.name;
		Debug.Log(ButtonName);
	}
}

 

기능이 같지만 버튼 이름이 다를 경우처럼 클릭한 오브젝트(버튼)의 이름을 가져오기 위한 방법입니다!

728x90
반응형

댓글