Files
Two-World/Assets/Cainos/Third Party/Lucid Editor/Editor/SerializedPropertyUtility.cs
2025-05-08 16:03:30 +09:00

32 lines
1.0 KiB
C#

using UnityEditor;
namespace Cainos.LucidEditor
{
public static class SerializedPropertyUtility
{
public static System.Type GetUnderlyingType(this SerializedProperty property)
{
System.Type parentType = property.serializedObject.targetObject.GetType();
System.Reflection.FieldInfo fi = parentType.GetFieldViaPath(property.propertyPath);
return fi.FieldType;
}
public static System.Reflection.FieldInfo GetFieldViaPath(this System.Type type, string path)
{
System.Type parentType = type;
System.Reflection.FieldInfo fi = type.GetField(path);
string[] perDot = path.Split('.');
foreach (string fieldName in perDot)
{
fi = parentType.GetField(fieldName);
if (fi != null)
parentType = fi.FieldType;
else
return null;
}
if (fi != null)
return fi;
else return null;
}
}
}