Get field

MeshBenth

☒Rustʕ•ᴥ•ʔRedux☒
Member
Oct 5, 2017
48
46
8
Parts Unknown
I want to get the value of each component on the object - is it possible?

GetComponent

C#:
public static ArrayList GetComponentsOfType<T>(GameObject o) where T : class {
  
    Component[] objs = o.GetComponents();
  
    ArrayList goodObjs = new ArrayList();
    T com;
  
    for (int i = 0; i < objs.Length; ++i) {
        com = objs[i] as T;
        if (com != null) {
            goodObjs.Add(com);
        }
    }
  
    return goodObjs;
}
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
I want to get the value of each component on the object - is it possible?

GetComponent

C#:
public static ArrayList GetComponentsOfType<T>(GameObject o) where T : class {
 
    Component[] objs = o.GetComponents();
 
    ArrayList goodObjs = new ArrayList();
    T com;
 
    for (int i = 0; i < objs.Length; ++i) {
        com = objs[i] as T;
        if (com != null) {
            goodObjs.Add(com);
        }
    }
 
    return goodObjs;
}
Components from a box?