This might be a reach, but is there a (non manual) means to get only the “Inspector-visible” properties of a given type?
For example, given someType as Collider, the code:
var myType : Type = someType.GetType();
var myInfoArray : PropertyInfo[] = myType.GetProperties();
returns not only the Inspector-visible properties, but as well the convenient and/or hidden ones, such as Transform, Renderer, and hideFlags.
Is there a way to parse for only what the Editor Inspector displays?
Not really understanding the question. Could you elaborate some more on what it is that you want?
When reflecting on a built-in type, want to show only properties that are visible in the inspector.
So, let’s use a Fixed Joint type, as an example:
- In the inspector, we see only 3 properties connectedBody, breakForce, breakTorque.
Reflecting the Fixed Joint type with the above PropertyInfo code, we’re returned the above properties, as well as 22 others; transform, renderer, active, tag, etc.
Desire to distill the results such I’m left only with the 3 Inspector-visible properties.
Thought perhaps there is a means to filter the results or perhaps use another unknown method using some known distinction, before I go manually parse the output with some crazy long switch to get what I want.
If it helps, this is a small module towards making a multi-object editor.
Ah. Take a look at the example provided with the Attribute class on msdn:
Thanks for the pointer, Emil. It’s strange that calling GetCustomAttributes returns an empty array whether called on MemberInfo or PropertyInfo elements…
As Sallah would say, I think I’m “digging in the wrong place!”
Hehe let me know how it goes. Looking forward to seeing the project in action
Will post to wiki if / when it’s ready
At the moment am still at it, but sadly not finding the actual attributes for a given built-in type; which obviously is critical to this class working.
Does Unity internally use the same attributes as users do? (for example, HideInInspector ) and if so, any ideas where that value is stored in relation to the property?
Without that info, I think the cool / reflected version is sunk!
No idea and I’m afraid my reflection experience is limited at best.