Skip to content

Instantly share code, notes, and snippets.

@neon-izm
Created January 27, 2019 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neon-izm/c2f535fc64ea31b28042848e11accce1 to your computer and use it in GitHub Desktop.
Save neon-izm/c2f535fc64ea31b28042848e11accce1 to your computer and use it in GitHub Desktop.
var eventFireingSystem = target as EventFireringSystem;
//適当なエディタ拡張内を想定してほしい
if (GUILayout.Button("イベント登録!"))
{
Debug.Log(path);
var go = GameObject.Find("Main Camera");
//GameObjectを引数に取るUnityEditor上のインスペクタ上で設定するイベントハンドラ
UnityAction<GameObject> action = new UnityAction<GameObject>(eventFireingSystem.TestFunctionArgNeedGameObject);
UnityEventTools.AddObjectPersistentListener<GameObject>(eventFireingSystem.fireEvents, action, go);
//こういう書き方だと、インスペクタ上に出てこないのでダメ!!
/*
eventFireingSystem.fireEvents.AddListener(delegate { SwitchButtonHandler(0); });
eventFireingSystem.fireEvents.Invoke();
*/
EditorUtility.SetDirty(eventFireingSystem);
//Persistent Event はシリアライズされたイベントのことです。
//言い換えればエディタから登録されたイベントです
Debug.Log($"eventFireingSystem.fireEvents.{eventFireingSystem.fireEvents.GetPersistentEventCount()} ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment