728x90
반응형
클릭한 버튼 오브젝트와 오브젝트 이름 가져오기
버튼을 클릭했을 때 , 해당 오브젝트의 이름에 따라서
동작하는 방법을 찾다가 클릭하는 오브젝트의 이름을 받아서
이름에 따라 조건을 주어서 이벤트를 발생하는 방법을 사용하게 되면서
다음과 같이 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;
}
}
728x90
반응형
'PROGRAMING📚 > Unity📑' 카테고리의 다른 글
[유니티 Unity] RenderTexture를 이용해서 UI에 영상 출력하기 (0) | 2022.11.25 |
---|---|
[유니티 Unity] 모바일 화면 자동 꺼짐 방지 하기 (0) | 2022.11.24 |
[유니티 Unity] 깃허브(github)에 유니티 프로젝트 올리기 (0) | 2022.11.23 |
[유니티 Unity] 비디오 영상 끝나는 시간 찾기 (0) | 2022.10.18 |
[유니티 Unity] 가상 키보드 만들기 (0) | 2022.09.26 |
댓글