public void Retry() { var callback = new MyUnityEvent(); callback.AddListener(() => ChangeLevel(CurrentLevel)); MyAdManager.Instance.ShowStageClearInterstitial(callback); }
public static void StartListening(string eventName, UnityAction <object[]> listener) { MyUnityEvent thisEvent; if (Instance._eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new MyUnityEvent(); thisEvent.AddListener(listener); Instance._eventDictionary.Add(eventName, thisEvent); } }
/// <summary> /// アクションが呼ばれるまで待機する /// </summary> public static IEnumerator WaitAction <T1, T2>(MyUnityEvent <T1, T2> action, Action callback = null) { bool isCalled = false; UnityAction <T1, T2> act = ((arg1, arg2) => isCalled = true); action.AddListener(act); yield return(new WaitUntil(() => isCalled)); action.RemoveListener(act); if (callback != null) { callback.Invoke(); } }
public static void startListen(TypeOfEvent theType, UnityAction <EventInfo> listener) { MyUnityEvent thisevent = null; if (eventManager.eventDictionary.TryGetValue(theType, out thisevent)) { thisevent.AddListener(listener); } else { thisevent = new MyUnityEvent(); thisevent.AddListener(listener); eventManager.eventDictionary.Add(theType, thisevent); } }
public void SubscribeEvent <T>(string _eventName, UnityAction <T> _functionCall) { UnityEventBase eventListener; if (m_FunctionWithNoParamDictionary.TryGetValue(_eventName, out eventListener)) { UnityEvent <T> unityEvent = eventListener as UnityEvent <T>; unityEvent.AddListener(_functionCall); } else { UnityEvent <T> unityEvent = new MyUnityEvent <T>(); unityEvent.AddListener(_functionCall); m_FunctionWithNoParamDictionary.Add(_eventName, unityEvent); } }
public static void AddEventListener(string eventName, UnityAction <object> callBackFunction) { MyUnityEvent _unityEvent; if (_eventDictionary.TryGetValue(eventName, out _unityEvent)) { _unityEvent.AddListener(callBackFunction); } else { _unityEvent = new MyUnityEvent(); _unityEvent.AddListener(callBackFunction); _eventDictionary.Add(eventName, _unityEvent); } Log.L("[EventManager] Add Listener : event = " + eventName + ", callback = " + callBackFunction.Target.ToString() + '.' + callBackFunction.Method.ToString()); }
// Update is called once per frame void Update() { uEvent.AddListener(Test); }