32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using Alchemy.Inspector;
|
|
using UnityEditor;
|
|
|
|
namespace Alchemy.Editor
|
|
{
|
|
/// <summary>
|
|
/// Alchemy Editor utility functions.
|
|
/// </summary>
|
|
public static class AlchemyEditorUtility
|
|
{
|
|
/// <summary>
|
|
/// Finds the type of drawer that corresponds to PropertyGroupAttribute.
|
|
/// </summary>
|
|
public static Type FindGroupDrawerType(PropertyGroupAttribute attribute)
|
|
{
|
|
return TypeCache.GetTypesWithAttribute<CustomGroupDrawerAttribute>()
|
|
.FirstOrDefault(x => x.GetCustomAttribute<CustomGroupDrawerAttribute>().targetAttributeType == attribute.GetType());
|
|
}
|
|
|
|
internal static AlchemyGroupDrawer CreateGroupDrawer(PropertyGroupAttribute attribute, Type targetType)
|
|
{
|
|
var drawerType = FindGroupDrawerType(attribute);
|
|
var drawer = (AlchemyGroupDrawer)Activator.CreateInstance(drawerType);
|
|
drawer.SetUniqueId("AlchemyGroupId_" + targetType.FullName + "_" + attribute.GroupPath);
|
|
return drawer;
|
|
}
|
|
}
|
|
}
|