private void InitializeFieldReflectionLists() { fields.Clear(); field_components.Clear(); field_names.Clear(); var all_components = L.GetComponents <MonoBehaviour>(); var flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Default; // Loop through each component foreach (var mb in all_components) { // Get all of the fields of this component FieldInfo[] component_fields = mb.GetType().GetFields(flags); foreach (FieldInfo f in component_fields) { // If the field is a public float if (f.FieldType == typeof(float)) { // Add it to all three lists fields.Add(f); field_names.Add(f.Name); field_components.Add(mb); } // else { Debug.Log("Ignored property " + f.Name); } } } // Make sure our lists are all the same length Debug.Assert(fields.Count == field_components.Count && fields.Count == field_names.Count); // Set our selected field index field_selected = field_names.FindIndex((x) => (x == L.target_field_name)); }