Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support private and protected Custom Properties #150

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public static void BroadcastProperty(this GameObject go, CustomProperty property
continue;
}

// Finally, look for public fields
// Finally, look for fields
var csfield = FindFieldBySignature(comp, property.m_Name, objValue.GetType());
if (csfield != null)
{
Expand All @@ -185,7 +185,7 @@ public static void BroadcastProperty(this GameObject go, CustomProperty property

private static MethodInfo FindMethodBySignature(MonoBehaviour component, string name, Type paramType)
{
return component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public).Where(info =>
return component.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(info =>
{
// Name must match
if (info.Name != name)
Expand Down Expand Up @@ -218,8 +218,7 @@ private static MethodInfo FindMethodBySignature(MonoBehaviour component, string

private static PropertyInfo FindPropertyBySignature(MonoBehaviour component, string name, Type valueType)
{
// Property must be public and instanced and writable
return component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public).Where(
return component.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(
info =>
info.CanWrite &&
info.Name == name &&
Expand All @@ -229,7 +228,7 @@ private static PropertyInfo FindPropertyBySignature(MonoBehaviour component, str

private static FieldInfo FindFieldBySignature(MonoBehaviour component, string name, Type valueType)
{
return component.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public).Where(
return component.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(
info =>
!info.IsInitOnly &&
info.Name == name &&
Expand Down