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 non-public fields too #45

Open
XtroTheArctic opened this issue Dec 28, 2021 · 3 comments
Open

Support non-public fields too #45

XtroTheArctic opened this issue Dec 28, 2021 · 3 comments
Labels
🐛 bug Something isn't working

Comments

@XtroTheArctic
Copy link

This may not be considered as a bug but I think it is because a serialized field in Unity is a serialized field, no matter if it's public or not.

My icon field is private and serialized but it doesn't display the icon in project view.

[SerializeField] [AssetIcon] Sprite Icon;

To support private serialized Unity fields, GetMembers call in AssetDrawerFactoryLibrary.cs should be changed to this:

var typeMembers = type.GetMembers(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
@XtroTheArctic XtroTheArctic added the 🐛 bug Something isn't working label Dec 28, 2021
@XtroTheArctic
Copy link
Author

XtroTheArctic commented Dec 30, 2021

Scratch the modified line in my original comment.

We need this entire block to be able to support inherited private fields.

                    var typeMembers = new List<MemberInfo>();
                    var typeToGetMembers = type;

                    do
                    {
                        typeMembers.AddRange(typeToGetMembers.GetMembers(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly));

                        typeToGetMembers = typeToGetMembers.BaseType;
                    }
                    while (typeToGetMembers != null);

@XtroTheArctic
Copy link
Author

@Fydar would you like to add this support please?

@XtroTheArctic
Copy link
Author

Hello. Is this project dead? It would be sad to see such a nice tool go out of active development/support. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant