/// <summary> /// Retourne Faux si la key n'existait pas /// </summary> private bool DrawData(DataType type, string key) { EditorGUILayout.BeginHorizontal(); var deleteKey = GUILayout.Button("X", GUILayout.Height(16), GUILayout.Width(16)); bool keyExists = true; switch (type) { case DataType.Int: { if (deleteKey) { gameSaves.DeleteInt(key); } EditorGUI.BeginChangeCheck(); var newValue = EditorGUILayout.DelayedIntField(key, gameSaves.GetInt(key)); keyExists = gameSaves.ContainsInt(key); if (EditorGUI.EndChangeCheck()) { gameSaves.SetInt(key, newValue); } break; } case DataType.Float: { if (deleteKey) { gameSaves.DeleteFloat(key); } EditorGUI.BeginChangeCheck(); var newValue = EditorGUILayout.DelayedFloatField(key, gameSaves.GetFloat(key)); keyExists = gameSaves.ContainsFloat(key); if (EditorGUI.EndChangeCheck()) { gameSaves.SetFloat(key, newValue); } break; } case DataType.String: { if (deleteKey) { gameSaves.DeleteString(key); } EditorGUI.BeginChangeCheck(); var newValue = EditorGUILayout.DelayedTextField(key, gameSaves.GetString(key)); keyExists = gameSaves.ContainsString(key); if (EditorGUI.EndChangeCheck()) { gameSaves.SetString(key, newValue); } break; } case DataType.Bool: { if (deleteKey) { gameSaves.DeleteBool(key); } EditorGUI.BeginChangeCheck(); var newValue = EditorGUILayout.Toggle(key, gameSaves.GetBool(key)); keyExists = gameSaves.ContainsBool(key); if (EditorGUI.EndChangeCheck()) { gameSaves.SetBool(key, newValue); } break; } case DataType.Object: { if (deleteKey) { gameSaves.DeleteObjectClone(key); } var obj = gameSaves.GetObjectClone(key); var text = key + ": " + (obj == null ? "null" : obj.GetType().ToString()); EditorGUILayout.LabelField(text); keyExists = gameSaves.ContainsObject(key); break; } default: EditorGUILayout.LabelField("Error type", EditorStyles.whiteBoldLabel); break; } EditorGUILayout.EndHorizontal(); return(keyExists); }