1
2
int index = 1;
button.onClick.AddListener(() => my.Function(index);
cs


해당 스크립트는 Play중에는 동작하지만 Button Inspector에는 변화가 없음.

Play중이 아닐 때 Inspector 자체에 추가하려면 아래와 같은 함수들을 사용해야함.


https://docs.unity3d.com/kr/current/ScriptReference/Events.UnityEventTools.html



1
2
3
4
5
var targetinfo = UnityEvent.GetValidMethodInfo(my, "FunctionName"new Type[] { typeof(string) });
string stringParameter = "test";
UnityAction<string> action = 
    Delegate.CreateDelegate(typeof(UnityAction<string>), myInstance, targetinfo, falseas UnityAction<string>;
UnityEventTools.AddStringPersistentListener(button.onClick, action, stringParameter);
cs


'Unity > Editor' 카테고리의 다른 글

ScriptableObject  (0) 2018.11.29
ReorderableList  (0) 2018.11.29
Unity 실행 시 에디터 스크립트 코드 실행  (0) 2018.11.21
트리뷰(TreeView)  (0) 2018.11.21
커스텀 에디터(CustomEditor)  (0) 2018.11.21

+ Recent posts