Send Event Argument Serialization

red_halo

New member
I've been under the impression the arguments listed in the SendEvent task inspector seemed incompatible with dynamic variables, since I wasn't able to see them listed even though they're defined throughout the tree. I thought it might be a Unity serialization quirk, so I made sure all changes were written to the tree asset by taking steps such as saving the Unity project, deleting the meta file, restarting unity, etc. Still no luck getting dynamic variables to appear.

I saw the SendEvent task argument variables were decorated with a [SharedRequired] attribute in code, so I chalked it up to it being by design. I can solve this for my needs by this by defining my own event task that could accommodate dynamic variables (the SetAgentDataEvent seen in the images below). No issues there.

However, today I noticed something peculiar which prompted me to start this thread.

In the image below, there's a standard SendEvent task disconnected from the rest of the tree towards the mid bottom. I was surprised to see three of the dynamic variables listed when I clicked on one of the argument fields.
1704116666236.png



That prompted me to conduct a simple experiment where I copied and pasted all of the original nodes into a new external behavior tree, and added the disconnected SendEvent task after. To my surprise, clicking on the argument field displays all of the dyanmic varaibles in this tree! After hooking it up to the tree and testing the value of the dynamic variable, everything seemed to work as expected. So it seems the SendEvent task is completely fine with dyanmic variables, if they are available as references.

Is the inability to initially see declared dyanmic variables in a SendEvent task a bug, or am I missing a step somewhere?
1704116702486.png
 
The SendEvent task uses a custom object drawer to draw its variables, and it looks like this object drawer doesn't implement the dynamic variable change. I will mark it down to take a look at in order to add support for it.
 
Top