1.5.0: Added interface and utility class for adding settings to toolbar settings provider
This commit is contained in:
parent
12de62dabb
commit
91c9504910
25 changed files with 272 additions and 133 deletions
43
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs
Normal file
43
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Module.NavigationTool.Editor.Toolbar
|
||||
{
|
||||
internal static class ToolbarSettingsUtility
|
||||
{
|
||||
public static IToolbarSettings[] GetAllSettings()
|
||||
{
|
||||
var list = new List<IToolbarSettings>(8);
|
||||
|
||||
try
|
||||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Type iType = typeof(IToolbarSettings);
|
||||
|
||||
for (var i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
Assembly assembly = assemblies[i];
|
||||
Type[] types = assembly.GetTypes();
|
||||
|
||||
for (var j = 0; j < types.Length; j++)
|
||||
{
|
||||
Type type = types[j];
|
||||
|
||||
if (!type.IsInterface && !type.IsAbstract && iType.IsAssignableFrom(type))
|
||||
list.Add((IToolbarSettings)FormatterServices.GetUninitializedObject(type));
|
||||
}
|
||||
}
|
||||
|
||||
list.Sort((s0, s1) => string.Compare(s0.Title, s1.Title, StringComparison.Ordinal));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
// Fail silently
|
||||
}
|
||||
|
||||
return list.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs.meta
Normal file
3
Editor/Toolbar/Utilities/ToolbarSettingsUtility.cs.meta
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c951cc6b880347bd9e710b8fee3788c5
|
||||
timeCreated: 1644864048
|
||||
|
|
@ -164,9 +164,7 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
{
|
||||
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
|
||||
Type iType = typeof(AbstractToolbarDrawer);
|
||||
|
||||
|
||||
|
||||
|
||||
for (var i = 0; i < assemblies.Length; i++)
|
||||
{
|
||||
Assembly assembly = assemblies[i];
|
||||
|
|
@ -180,6 +178,8 @@ namespace Module.NavigationTool.Editor.Toolbar
|
|||
list.Add((AbstractToolbarDrawer)FormatterServices.GetUninitializedObject(type));
|
||||
}
|
||||
}
|
||||
|
||||
list.Sort((t0, t1) => t0.Priority.CompareTo(t1.Priority));
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue