Search Unity

Feature Request c# custom UnitCategory for events

Discussion in 'Visual Scripting' started by IAndrewNovak, Oct 5, 2021.

  1. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    118
    I Used a simple class for my custom event. After saving the script and regenerate units in Protect Settings I have Game->Events->"EmptyCategory" without the event in fuzzy finder.

    I trying [UnitCategory("Game/Events/Global")] and [UnitCategory("Game\\Events\\Global")] - have same result.

    It's a bug or I doing something wrong?


    Code (CSharp):
    1. [UnitTitle("OnTriggerPlayerEnter")]
    2. [UnitCategory("Game\\Events\\Global")]
    3. public class TriggerPlayerEnterEvent : GameObjectEventUnit<PlayerCharacter>
    4. {
    5.     [DoNotSerialize]
    6.     public ValueOutput player { get; private set; }
    7.  
    8.     protected override string hookName => CustomEventNames.TriggerPlayerEnterEvent;
    9.     public override Type MessageListenerType => null;
    10.  
    11.     protected override void Definition()
    12.     {
    13.         base.Definition();
    14.  
    15.         player = ValueOutput<PlayerCharacter>(nameof(player));
    16.     }
    17.  
    18.     protected override void AssignArguments(Flow flow, PlayerCharacter data)
    19.     {
    20.         flow.SetValue(player, data);
    21.     }
    22. }
     
  2. ericb_unity

    ericb_unity

    Unity Technologies

    Joined:
    Nov 24, 2017
    Posts:
    167
    Events are special snowflakes at the moment. they need to be the Event folder. You will need to set them like this to see them. Or you will only be able to find them by typing the name of the event node.
    [UnitCategory("Events\\Game\\Global")]
     
  3. IAndrewNovak

    IAndrewNovak

    Joined:
    Nov 29, 2013
    Posts:
    118
    Thanks for the info.

    I hope in the future it will be possible to create your own category and move all there. This is a very useful thing when we write nodes and events for designers and group them in one place.
     
    ericb_unity likes this.