From 6fc88d39861e433a088537d36f0f5e6890c8b6bd Mon Sep 17 00:00:00 2001 From: Anders Ejlersen Date: Sat, 18 Sep 2021 10:52:40 +0200 Subject: [PATCH] 0.8.0: Fixed issue, where a compiler error could result in a cascade of reflection exceptions from the toolbar --- Editor/Toolbar/Utilities/ToolbarUtility.cs | 31 ++++++++++++++-------- package.json | 2 +- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Editor/Toolbar/Utilities/ToolbarUtility.cs b/Editor/Toolbar/Utilities/ToolbarUtility.cs index 3f9fdb5..ad5a793 100644 --- a/Editor/Toolbar/Utilities/ToolbarUtility.cs +++ b/Editor/Toolbar/Utilities/ToolbarUtility.cs @@ -134,25 +134,34 @@ namespace Module.NavigationTool.Editor.Toolbar public static AbstractToolbarDrawer[] GetAllDrawers() { - Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); - Type iType = typeof(AbstractToolbarDrawer); - var list = new List(8); - for (var i = 0; i < assemblies.Length; i++) + try { - Assembly assembly = assemblies[i]; - Type[] types = assembly.GetTypes(); + Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); + Type iType = typeof(AbstractToolbarDrawer); - for (var j = 0; j < types.Length; j++) + + + for (var i = 0; i < assemblies.Length; i++) { - Type type = types[j]; + Assembly assembly = assemblies[i]; + Type[] types = assembly.GetTypes(); - if (!type.IsAbstract && iType.IsAssignableFrom(type)) - list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type)); + for (var j = 0; j < types.Length; j++) + { + Type type = types[j]; + + if (!type.IsAbstract && iType.IsAssignableFrom(type)) + list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type)); + } } } - + catch (Exception) + { + // Fail silently + } + return list.ToArray(); } } diff --git a/package.json b/package.json index 0c0f069..72e8bdf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.module.navigationtool", - "version": "0.7.2", + "version": "0.8.0", "displayName": "Module.NavigationTool", "description": "Support for navigation tools, like favorites, history and toolbars", "unity": "2019.2",