diff --git a/Assets/Fungus/Scripts/Editor/EditorExtensions.cs b/Assets/Fungus/Scripts/Editor/EditorExtensions.cs index 20028c7c..cce6da06 100644 --- a/Assets/Fungus/Scripts/Editor/EditorExtensions.cs +++ b/Assets/Fungus/Scripts/Editor/EditorExtensions.cs @@ -4,6 +4,7 @@ using UnityEngine; using System.Collections.Generic; using System.Linq; +using UnityEditor; namespace Fungus.EditorUtils { @@ -52,7 +53,7 @@ namespace Fungus.EditorUtils } /// - /// A convenient method for calling the above. + /// A convenient method for calling the above, but for ALL assemblies. /// Example usage: /// List subTypes = EditorUtility.FindDerivedTypes(typeof(BaseTimelineEvent)).ToList(); /// @@ -61,7 +62,21 @@ namespace Fungus.EditorUtils /// public static System.Type[] FindDerivedTypes(System.Type baseType, bool classOnly = true) { - return FindDerivedTypesFromAssembly(System.Reflection.Assembly.GetAssembly(baseType), baseType, classOnly); +#if UNITY_2019_2_OR_NEWER + var results = TypeCache.GetTypesDerivedFrom(baseType).ToArray(); + if (classOnly) + return results.Where(x => x.IsClass).ToArray(); + else + return results.ToArray(); +#else + System.Type[] typeArray = new System.Type[0]; + var retval = typeArray.Concat(typeArray); + foreach (var assem in System.AppDomain.CurrentDomain.GetAssemblies()) + { + retval = retval.Concat(FindDerivedTypesFromAssembly(assem, baseType, classOnly)); + } + return retval.ToArray(); +#endif } } } \ No newline at end of file