Cannot pass UnityEvent<string> parameter value when invoking the callback

@ChrisP999 It is even more confusing that the Dynamic has just the name of the method, without the arguments list, looking like a property, while the Static has the argument list, looking like the method we are trying to reference.
That parameter list led me to wrongly choose static the first time I used this.

The static version gets the argument value from the inspector, rather than from the runtime code. This is noticeable from the additional field in the Inspector:

9544789--1348231--upload_2023-12-23_6-10-10.png

As shown by @Kurt-Dekker here:

We need to reference the GameObject where the script is attached to, rather than the script itself.
And again confusingly, when the gameobject is defined initially it shows the cube icon for an object, but after choosing the callback method it changes to the c# script icon, as in the above figure.

Edit: It also accepts a ScriptableObject, and a Prefab. Since GameObject and ScriptableObject are subclasses of System.Object to accept both the type of this field must be a System.Object. But this way it accepts anything.

If willing to change this behaviour I guess we could rewrite UnityEventDrawer code:


9544789--1348225--upload_2023-12-23_5-58-56.png
9544789--1348225--upload_2023-12-23_5-58-56.png

1 Like