I know I can find a list of scripts (components) on an object thus:
Component[] ss = (Component[])oldTr.GetComponents (typeof(Component));
The question is, is there a way to get the 'custom attributes' or properties or variables on those scripts, without knowing the script's API, so to speak?
In other words, I want to walk through all scripts attached to an object and get all the variables (name and value) for each.
Component[] cs = (Component[])oldTr.GetComponents (typeof(Component));
foreach (Component c in cs)
{
Debug.Log("name "+c.name+" type "+c.GetType() +" basetype "+c.GetType().BaseType);
foreach( FieldInfo fi in c.GetType().GetFields() )
{
System.Object obj = (System.Object)c;
Debug.Log("fi name "+fi.Name+" val "+fi.GetValue(obj));
}
This is a comment - comments just don't allow space and formatting.
I was looking for the same feature but could not find any docs on those methods.
Can you point to the documentation that covers them?
I am not a C# programmer, I use UnityScript, but I trimmed down your code to get it passed the assembly reference error: (...I am not sure what should be in the 'using (Ref);')