1.5.0: Added IntToLayerMask, marked QuaternionToEuler as obsolete as of 2021 and fixed a couple of bugs

- Drawer: Added IntToLayerMaskAttribute, if a raw int is wanted instead of LayerMask
- Drawer: Added option to either use full or short type name, when using SerializeReferenceTo
- Extension: Fixed issue, where GetValueType and GetValue for SerializedProperty would throw exceptions, if field is private
This commit is contained in:
Anders Ejlersen 2022-06-26 15:06:52 +02:00
parent ee7326c33a
commit 7d99d62e11
14 changed files with 114 additions and 17 deletions

View file

@ -402,13 +402,17 @@ namespace Module.Inspector.Editor
private static object GetValue(this SerializedProperty property)
{
const BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
object obj = property.serializedObject.targetObject;
foreach (string path in property.propertyPath.Split('.'))
{
Type type = obj.GetType();
FieldInfo field = type.GetField(path);
obj = field.GetValue(obj);
FieldInfo field = type.GetField(path, FLAGS);
if (field != null)
obj = field.GetValue(obj);
}
return obj;
@ -416,12 +420,15 @@ namespace Module.Inspector.Editor
public static Type GetValueType(this SerializedProperty property)
{
const BindingFlags FLAGS = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
object obj = property.serializedObject.targetObject;
Type type = null;
foreach (string path in property.propertyPath.Split('.'))
{
FieldInfo field = obj.GetType().GetField(path);
Type objType = obj.GetType();
FieldInfo field = objType.GetField(path, FLAGS);
if (field == null)
continue;