using System;
using System.Linq;
using System.Reflection;
using Alchemy.Inspector;
using UnityEditor;
namespace Alchemy.Editor
{
///
/// Alchemy Editor utility functions.
///
public static class AlchemyEditorUtility
{
///
/// Finds the type of drawer that corresponds to PropertyGroupAttribute.
///
public static Type FindGroupDrawerType(PropertyGroupAttribute attribute)
{
return TypeCache.GetTypesWithAttribute()
.FirstOrDefault(x => x.GetCustomAttribute().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;
}
}
}