+2
Completed

UnityEvent Support

Lazlo Bonin (Lead Developer) 4 years ago updated by Lauwisme 1 year ago 11

There should be a way to trigger a custom event from a UnityEvent inspector. 

There would be a few overloads to the helper method to support every Unity parameter type:

  • No argument
  • String argument
  • Float argument
  • Int argument
  • Unity Object argument
Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
+2

The only supported parameter is a string that is the name of the event:



Awesome 

Perfect for DOTween 😍

This is fine, but it's really no different from wiring up an explicit function call- ie., the component has to explicitly call a specific action on a specific object.. for each object that wants to receive its events. It would be nice if the component could just Invoke the event and not know or care what may or may not be listening. Is there any way to tell a flow  graph to subscribe to an event? I'd like to just drag an object and pull out a list of events it fires.
Eg.
class SomeEvent : UnityEvent<int, int, int, string, Transform….any parameters I want> {}

And then elsewhere just call
SomeEvent?Invoke(…)

Unless I'm mistaken, you can trigger a UnityEvent even if there is no UnityEvent listener unit in the graph. There shouldn't be any error or even warning.

As for multi-parameter events, that's simply not supported by UnityEvents. It is however supported in Bolt's Custom Events.

+1

I can’t find the option for trigger unity event in the drop box menu. Is there any way to do in setting?

Has something changed since implementing this? Somehow I don't get to set the name of the UnityEvent as an argument, see below.



I'm on 2019.3.0f6 btw

That's odd
When I use it in 2019.3.0f6i get it like it should be
Can you try it with other event trigger?

Nevermind me, I've never used these. I took the one from the top, didn't notice the other (with argument) untill just now...