본문 바로가기
개발/Unity

Unity) Unity Events (Inpsector Unity Event)

by 테샤르 2022. 1. 17.

Unity Events

UnityEvents는 추가 프로그래밍 및 스크립트 구성 없이 편집 시간부터 런타임까지 사용자 주도 콜백이 지속되도록 하는 방법으로 Insepctor에 연결해서 이벤트를 사용할 수 있다.

 

대표적인 이벤트 형태로는 Button 의 onClick 이벤트 등이 있다.

 

사용방법의 순서는 다음과 같다.

  1. 스크립트가 를 가져오거나 사용하는지 확인하십시오 UnityEngine.Events.
  2. + 아이콘을 선택하여 콜백 슬롯을 추가합니다.
  3. 콜백을 수신하려는 UnityEngine.Object를 선택합니다(이를 위해 개체 선택기를 사용할 수 있음).
  4. 호출하려는 기능을 선택하십시오
  5. 이벤트에 대해 둘 이상의 콜백을 추가할 수 있습니다.
  6.  
반응형

 

Custom Class로 만들면 다음과 같다.

using UnityEngine.Events;

[System.Serializable]
public class CustomUnityEvent : UnityEvent<GameObject>
{
   
}
  [SerializeField]
    private CustomUnityEvent CustomEvent = null;

 

 

 

Unity Event : [링크]

 

Unity - Manual: UnityEvents

Null Reference Exceptions UnityEvents UnityEvents are a way of allowing user driven callback to be persisted from edit time to run time without the need for additional programming and script configuration. UnityEvents are useful for a number of things: Con

docs.unity3d.com

 

★☆☆☆☆

 

반응형

댓글