/// <summary> /// Subscribe to a specific event type (only be notified of a specific event type) /// </summary> public Subscription Subscribe(Action <ScriptableEvent> action, ScriptableEvent eventType) { var publisher = eventPublisherCatalog.Find(eventType); publisher.Subscribe(action); return(Subscription.Create(publisher, action)); }
public void RaiseEvent(ScriptableEvent eventType) { if (debug) { Debug.Log("EVENT: " + eventType.name); } // Raise general events eventPublisher.RaiseEvent(eventType); // Raise subscribed events eventPublisherCatalog.Find(eventType).RaiseEvent(eventType); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.enabled = Application.isPlaying; ScriptableEvent e = target as ScriptableEvent; if (GUILayout.Button("Raise")) { e.Raise(); } }
/// <summary> /// Register an event to be reset at the end of a frame /// </summary> /// <param name="scriptableEvent">Event to be reset</param> public static void RegisterEventForReset(ScriptableEvent scriptableEvent) { if (Instance != null) { Instance.StartCoroutine(ResetOnEndOfFrame()); } else { throw new System.Exception("Event Tracker is not yet ready"); } IEnumerator ResetOnEndOfFrame() { yield return(new WaitForEndOfFrame()); scriptableEvent.Reset(); } }
public void StartTimer(double timeToTrigger, ScriptableEvent targetEvent, DateTimeValue nextEventValue, bool keepAlive) { if (keepAlive) { DontDestroyOnLoad(this); } timeTrigger = timeToTrigger; dateTimeInitializer = nextEventValue; eventTarget = targetEvent; if (currentRoutine != null) { return; } Init(); currentRoutine = StartCoroutine(RunTimerEvent()); }
private void OnRaisedEvent(ScriptableEvent scriptableEvent) { unityEvent.Invoke(); }
public void OnDisable() { ScriptableEvent?.RemoveListener(this); }
public void OnEnable() { ScriptableEvent?.AddListener(this); }
public void RaiseEvent(ScriptableEvent eventType) { onEvent(eventType); }