- Home /
How to make event trigger with custom events??
Hi, I'm not sure if anybody can help with this problem, but here's the thing:
I'm trying to make system based on single manager, invoking events (about current level states), and listeners that will react to this events. Example:
And I would like to be able to set reactions similar to event trigger, but with custom defined events.
Is there any way to make similar component to event trigger, where it will be possible to use custom list of events (that wil be defined either in manager or separately)? Or is there even some better solution for this situation? If you have any idea, I'll be glad for any tip or advice, thanks.
Answer by SlowCircuit · Sep 21, 2020 at 11:47 PM
It seems like you want to use UnityEvent. Just decalare a variable like:
public UnityEvent NameOfVariable;
It will show up in the inspector just like the pointer exit and enter events you have there. When you want to call the event just use:
NameOfVariable.Invoke();
Yes, that might be right direction. But with event trigger you can add different event types (e.g. pointer enter). In this system I would like to be able to add custom events types. If we base it on my chart example, it should show options "OnDay", "OnNight", "OnRain" when I click on "Add New Event Type" button, instead of its default input events. Visual it could looks/works like this:
Invokation of events should also be done by one central manager and other prefabs should only subscribe to manager. Problem is, that I can't see how it is possible to define my "Events list" and apply it when adding new event type.
Your answer
Follow this Question
Related Questions
Method doesn't get implemented after subscribing to Func 1 Answer
How to make events only trigger for specific object? 0 Answers
Is there any event or delegate that is called with OnValidate() ? 0 Answers
Unity Events - Subscribe and Unsubscribe Odd Behavor 0 Answers
Using Delegates for separating UI and Logic, are these in the right place? 1 Answer