Files
Hasebe/Library/PackageCache/com.annulusgames.alchemy@1402075f473d/Editor/AlchemyEditorUtility.cs
T
2026-09-21 12:15:57 +03:00

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;
}
}
}