UnityEvent in Inspector

Matthew57

New member
Instead of displaying the raw data of what the arguments for UnityEvent, it would be great to be able to use the default dropdown interface that's used everywhere else
 

Attachments

  • UnityEvent.JPG
    UnityEvent.JPG
    25.2 KB · Views: 13
  • EventB.JPG
    EventB.JPG
    15.7 KB · Views: 14
Yes, I plan on adding this to the next version. I'll let you know after I add it and if you send me a PM with your BD invoice number and Unity version I can send it to you before release.
 
I was looking into this and unfortunately it doesn't look like it's possible to do with IMGUI. Behavior Designer tasks are not Unity Objects so I can't use EditorGUI.PropertyField (which is how Unity draws the events). I would instead have to use something like EditorGUI.UnityEvent but that method does not exist. Maybe with Unity's new UIElements solution I'll be able to add better Unity Event support.
 
It’s already being done though. If you look at the InvokeMethod action class in the inspector it has a version of the unityevent. It’s not the exact same as what normal unityevents looks like but it serves the purpose well enough. If we can just use that same inspector code that’s all we’ll need.
 
InvokeEvent uses a custom implementation specific for the reflection tasks, and it's not really easy to extend for the Unity Event system. I am currently working on a UIElements version of Behavior Designer and I haven't gotten to the part where I can draw fields but UIElements offers a lot more flexibility so I am hopeful that it is included in that.
 
InvokeEvent uses a custom implementation specific for the reflection tasks, and it's not really easy to extend for the Unity Event system. I am currently working on a UIElements version of Behavior Designer and I haven't gotten to the part where I can draw fields but UIElements offers a lot more flexibility so I am hopeful that it is included in that.

Hi Justin, has this been implement yet? I still see the raw data and not the default interface.
 
No, this will require a UIElements version in order to implement correctly.
 
It would be nice to have the UnityEvents supported, with proper drawers, in the Behaviour Designer by default.
We have some niche use cases, where we have many many different events could fire based on a single node.

We have between 25 nodes that could trigger up to 5 different results.
If we could link UnityEvents inside the 25 nodes then we will have a very clean Behaviour Tree.
But if we use the Behvaiour Designer Events, then now we need to create 25x5=125 different nodes for each condition that could be met, the tree will become messy and it would be a mission to maintain.
 
For that specific use can you can use Behavior Designer events:


Within a task you can register for the event with:

Code:
Owner.RegisterEvent(...)

Owner points to the current Behavior Tree object.
 
For that specific use can you can use Behavior Designer events:


Within a task you can register for the event with:

Code:
Owner.RegisterEvent(...)

Owner points to the current Behavior Tree object.

We have this class:
Code:
public class Response{
    public string id;
    public List<UnityEvent> events; // Not sure what this would be for Behaviour Designer Events
}

Which will be used in the node class like:
Code:
    public List<Response> response;

This node currently has 5 possible outcomes: ID 1,2,3,4, 99.

Based on which ID is the outcome, it needs to trigger the events associated with that ID.

We need to be able to pass a list of Response items that contains a ID, and then a List of Events for that ID into the node.

The problem that we're experiencing is that the events are not displaying correctly within the Behaviour Designer, so we can't effectively use it.

I had a look at the Behaviour Events, but it looks like they need to be scripted before the time, and can't be populated in the Editor like you would do with a UnityEvent.

Please let me know if I am missing something obvious.
But I couldn't find a way in your documentation to achieve this.
 
Instead of List<UnityEvent> you'd have a struct list. It could be something like:

Code:
public struct MyEvent
{
   string name;
   int value;
}
You'd then have List<MyEvent>. Instead of calling UnityEvent.Invoke you'd call Owner.SendEvent(MyEvent.name, ...). With this setup you have the same functionality as Unity events, and it will also show in the inspector.
 
Top