arimger / Unity-Editor-Toolbox

Tools, custom attributes, drawers, hierarchy overlay, and other extensions for the Unity Editor.
MIT License
1.73k stars 125 forks source link

Is it possible to list all interface type ? #76

Closed YouKiat closed 1 year ago

YouKiat commented 1 year ago
        [field: TypeConstraint(null,
            AllowAbstract = true,
            AllowObsolete = true,
            AddTextSearchField = true,
            OrderTypes = true,
            TypeGrouping = TypeGrouping.ByFlatName,
            TypeSettings = TypeSettings.Interface)]
        private SerializedType InterfaceType { get; set; } = new();

I tried the code above, but it didn't work.

arimger commented 1 year ago

Unfortunately not, you have to specify the base class. SerializedType underneath is using the TypeCache class and as far as I know, there is no option to get all interfaces. Previously I was using a custom solution that scans all assemblies but for Editor Tools is highly advised to use the TypeCache to share the same API for retrieving types.

YouKiat commented 1 year ago

ok, noted, thanks.