animancer icon indicating copy to clipboard operation
animancer copied to clipboard

Add BidingFlags.FlattenHeirarchy to AnimancerEditorUtilities.StaticBindings

Open doug-w opened this issue 1 year ago • 2 comments

Use Case

I have a case where some Event Names are used in some places while a superset is used elsewhere. I've set this up as:

public static class BaseEventNames {
    public static string EventName1 = "EventName1";
};

public static class SpecializedEventNames : BaseEventNames {
    public static string SpecialEventName1 = "SpecialEventName1";
}

public class AnimationHolder {
    [EventNames(typeof(SpecializedEventNames ))] MyAnimationHolder specialAnimation;
    [EventNames(typeof(BaseEventNames ))] MyAnimationHolder baseAnimation;
};

By default the editor will only see the SpecializedEventNames and not the inherited BaseEventNames in the EventNames dropdown.

Solution

Setting AnimancerEditorUtilities.StaticBindings as: StaticBindings = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.FlattenHierarchy; shows the full set of event names.

doug-w avatar Jul 02 '24 23:07 doug-w

Your solution seems to work, though StaticBindings is used in a few other places so I might end up putting FlattenHierarchy just in where it's used by the event names system. I'll need to look into it more closely.

KybernetikGames avatar Jul 03 '24 08:07 KybernetikGames