public void ForEachPropertyInGroup(string grp, System.Action <BTPrjSetting> d) { EnumFields(); int iter = 0;; foreach (var field in fields) { var prop = new BTPrjSetting(); prop.dispName = DispName(field.Name); prop.format = BTSFormat.Undefined; prop.index = iter++; prop.key = field.Name; prop.needsChange = false; prop.type = Type2ST(field.FieldType); d(prop); } }
public void ForEach(System.Action <BTPrjSetting> d) { foreach (var k in keys) { var s = new BTPrjSetting(); int i = keys.IndexOf(k); s.index = i; s.key = k; s.dispName = dispName[i]; s.type = Str2ST(types[i]); s.defaultValue = defaultValue[i]; s.value = value[i]; s.writeEnabled = writeEnabled[i]; s.needsChange = needsChange[i]; s.format = IntToFormat(format[i]); d(s); } }
public void ForEachPropertyInGroup(string grp, System.Action <BTPrjSetting> d) { for (int i = 0; i < keys.Count; i++) { string k = keys[i]; //string v = value[i]; string g = group[i].ToLower(); if (g == grp.ToLower()) { var s = new BTPrjSetting(); s.index = i; s.key = k; s.dispName = dispName[i]; s.type = Str2ST(GetPropertyTypeAsString(i)); s.defaultValue = defaultValue[i]; s.value = value[i]; s.writeEnabled = writeEnabled[i]; s.needsChange = needsChange[i]; s.format = IntToFormat(format[i]); d(s); } } }
public static void DrawProperty(IPropertiesInfoSet p, BTPrjSetting setting, ref int numNC, ref bool hasChanged) { int i = setting.index; string k = setting.key; var wr = p.WriteEnabled(k); if (wr) { GUI.enabled = true; bool nc = p.NeedsChange(k) && p.HasChangedFromDefault(k); if (nc) { numNC++; } var normColor = GUI.color; GUI.color = nc ? Color.yellow : normColor; string reason = ""; if (nc == false && p.IsValidValue(k, out reason) == false) { GUI.color = Color.red; } //GUILayout.Label( "" + p.DispName( k ) + " = " + p.GetValue( k ) ); string oldvalue = p.GetValue(k); string strT = p.GetStrType(k); if (strT.StartsWith("string:")) { var str_options = strT.Replace("string:", "").Replace(" ", "").Split(new char[] { ',' }).ToList(); int iof = str_options.IndexOf(p.GetValue(i)); string str_option = str_options[iof]; if (str_options.Count > 0) { GUILayout.BeginHorizontal(); GUILayout.Label("" + k, GUILayout.Width(145)); int inew = EditorGUILayout.Popup(iof, str_options.ToArray()); if (inew != iof) { iof = inew; //Debug.Log( "SetVAlue = str_options[iof] = " + str_options[iof] ); p.SetValue(k, str_options[iof]); } GUILayout.EndHorizontal(); } else { GUI.enabled = false; EditorGUILayout.TextField(p.DispName(k), "NO OPTIONS AVAIL"); } } else { try { bool drawn; object objvalue = FieldByType(p.GetSystemType(k), p.DispName(k), p.GetValueAsRealButAnonType(k), out drawn); string strNewVal = System.Convert.ToString(objvalue); if (strNewVal != oldvalue) { hasChanged = true; if (strNewVal == "") { //Debug.LogError("new value is empty"); } //Debug.Log( "Setting value : oldval = " + oldvalue + " newv=" + strNewVal ); p.SetValue(k, strNewVal); } } catch (System.Exception e) { Debug.LogError("" + e); } } if (!string.IsNullOrEmpty(reason)) { GUILayout.Label("* " + reason); } GUI.color = normColor; } else { GUI.enabled = false; EditorGUILayout.TextField(p.DispName(k), p.GetValue(k)); } }