private void DrawLevels() { EditorGUILayout.LabelField("Levels", _headerStyle); EditorGUILayout.BeginVertical(GUI.skin.box); { if (GUILayout.Button("Add level")) { RecordObject("Level Settings Change"); var levelSettings = new LevelSettings(); if (GameConfiguration.Instance.Levels.Count > 0) { var prevLevelSettings = GameConfiguration.Instance.Levels[GameConfiguration.Instance.Levels.Count - 1]; levelSettings.Copy(prevLevelSettings); } GameConfiguration.Instance.Levels.Add(levelSettings); } _levelsContentPosition = EditorGUILayout.BeginScrollView(_levelsContentPosition); { var levels = _serializedObject.FindProperty("Levels"); var count = levels.arraySize; for (var i = 0; i < count; i++) { var element = levels.GetArrayElementAtIndex(i); var level = element.FindPropertyRelative("Level"); var score = element.FindPropertyRelative("Score"); element.isExpanded = EditorGUILayout.Foldout(element.isExpanded, $"Level {level.intValue} : {score.intValue}", true); if (element.isExpanded) { EditorGUILayout.BeginHorizontal(GUI.skin.box); { EditorGUILayout.BeginVertical(); { EditorGUILayout.PropertyField(level); EditorGUILayout.PropertyField(score); } EditorGUILayout.EndVertical(); if (GUILayout.Button("X", GUILayout.Width(20))) { RecordObject("Level Settings Change"); GameConfiguration.Instance.Levels.RemoveAt(i); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.Space(); } } EditorGUILayout.EndScrollView(); } EditorGUILayout.EndVertical(); }