KybernetikGames / animancer

Documentation for the Animancer Unity Plugin.
68 stars 8 forks source link

Add BidingFlags.FlattenHeirarchy to AnimancerEditorUtilities.StaticBindings #353

Closed doug-w closed 3 months ago

doug-w commented 4 months ago

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.

KybernetikGames commented 4 months ago

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 commented 4 months ago

Animancer v8.0a3 is now available for Alpha Testing and includes this fix..

KybernetikGames commented 3 months ago

Animancer v8.0 is now fully released.