Fix: fields that hides inherited properties appears multiple times

This commit is contained in:
AnnulusGames 2024-02-17 15:27:14 +09:00
parent 6800d3a455
commit aff108be38
2 changed files with 5 additions and 12 deletions

View File

@ -211,7 +211,11 @@ namespace Alchemy.Editor
break;
case FieldInfo:
case PropertyInfo:
if (memberInfo.IsPublic() || memberInfo.HasCustomAttribute<SerializeField>())
var isSerializedMember = false;
if (memberInfo is FieldInfo f) isSerializedMember = f.IsPublic | f.HasCustomAttribute<SerializeField>();
else if (memberInfo is PropertyInfo p) isSerializedMember = p.HasCustomAttribute<SerializeField>();
if (isSerializedMember)
{
var property = findPropertyFunc?.Invoke(memberInfo.Name);

View File

@ -15,16 +15,5 @@ namespace Alchemy.Editor
result = memberInfo.GetCustomAttribute<T>();
return result != null;
}
public static bool IsPublic(this MemberInfo memberInfo)
{
switch (memberInfo)
{
case MethodInfo methodInfo: return methodInfo.IsPublic;
case FieldInfo fieldInfo: return fieldInfo.IsPublic;
case PropertyInfo propertyInfo: return propertyInfo.GetMethod != null && propertyInfo.GetMethod.IsPublic && propertyInfo.SetMethod != null && propertyInfo.SetMethod.IsPublic;
default: throw new NotSupportedException();
}
}
}
}