Skip to content

Commit f42adcb

Browse files
committed
Built-in assemblies aren't searched for IRuntimeInspectorCustomEditors to improve assembly search performance
1 parent d1d8512 commit f42adcb

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

Plugins/RuntimeInspector/Scripts/RuntimeInspector/Helpers/RuntimeInspectorUtils.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,12 +782,53 @@ public static IRuntimeInspectorCustomEditor GetCustomEditor( Type type )
782782

783783
#if UNITY_EDITOR || !NETFX_CORE
784784
// Search all assemblies for RuntimeInspectorCustomEditor attributes
785+
// Don't search built-in assemblies for custom editors since they can't have any
786+
string[] ignoredAssemblies = new string[]
787+
{
788+
"Unity",
789+
"System",
790+
"Mono.",
791+
"mscorlib",
792+
"netstandard",
793+
"TextMeshPro",
794+
"Microsoft.GeneratedCode",
795+
"I18N",
796+
"Boo.",
797+
"UnityScript.",
798+
"ICSharpCode.",
799+
"ExCSS.Unity",
800+
#if UNITY_EDITOR
801+
"Assembly-CSharp-Editor",
802+
"Assembly-UnityScript-Editor",
803+
"nunit.",
804+
"SyntaxTree.",
805+
"AssetStoreTools",
806+
#endif
807+
};
808+
809+
CompareInfo caseInsensitiveComparer = new CultureInfo( "en-US" ).CompareInfo;
810+
785811
foreach( Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() )
786812
{
787813
#if NET_4_6 || NET_STANDARD_2_0
788814
if( assembly.IsDynamic )
789815
continue;
790816
#endif
817+
818+
string assemblyName = assembly.GetName().Name;
819+
bool ignoreAssembly = false;
820+
for( int i = 0; i < ignoredAssemblies.Length; i++ )
821+
{
822+
if( caseInsensitiveComparer.IsPrefix( assemblyName, ignoredAssemblies[i], CompareOptions.IgnoreCase ) )
823+
{
824+
ignoreAssembly = true;
825+
break;
826+
}
827+
}
828+
829+
if( ignoreAssembly )
830+
continue;
831+
791832
try
792833
{
793834
foreach( Type _type in assembly.GetExportedTypes() )

0 commit comments

Comments
 (0)