void Start() { ca = new subClassA(1, 2, 3); cb = new subClassB(); cc = new subClassC(); FieldInfo[] fields = typeof(subClassA).GetFields(); foreach (FieldInfo field in fields) { Debug.Log(field.Attributes + " " + field.FieldType + " " + field.Name); } // This code reveals all of the functions, fields, and attributes associated with the function and fields of the class. MemberInfo[] memberInfos = typeof(subClassA).GetMembers(); foreach (MemberInfo m in memberInfos) { Debug.Log(m.ToString()); } }
// Use this for initialization void Start() { ca = new subClassA(1, 2, 3); cb = new subClassB(); cc = new subClassC(); FieldInfo[] fields = typeof(subClassA).GetFields(); foreach (FieldInfo field in fields) { Debug.Log(field.Attributes + " " + field.FieldType + " " + field.Name); if (field.FieldType == typeof(string)) { field.SetValue(ca, "I found a string!"); } } MemberInfo[] memberInfos = typeof(subClassA).GetMembers(); foreach (MemberInfo m in memberInfos) { Debug.Log(m.ToString()); } Debug.Log(ca.secondInt); }