public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { // Get sub properties SerializedProperty type = property.FindPropertyRelative(nameof(type)); SerializedProperty index = property.FindPropertyRelative(nameof(index)); // Set height for just one control position.height = LayoutUtilities.standardControlHeight; // Put in the property foldout property.isExpanded = EditorGUI.Foldout(position, property.isExpanded, label); position.y += position.height; if (property.isExpanded) { // Increse indent EditorGUI.indentLevel++; // Edit the type EditorGUI.PropertyField(position, type); position.y += position.height; // Get a list of all possible level ids with this type LevelID[] levelIDs = LevelSettings.GetAllLevelIDsOfType((LevelType)type.enumValueIndex); // Select the names of the levels with this type string[] names = levelIDs.Select(id => id.Data.EditorDisplayName).ToArray(); // Edit the property as a popup with the names of all the levels in this type index.intValue = EditorGUIExt.Popup(position, index.intValue, names, new GUIContent(property.displayName)); // Resume indent EditorGUI.indentLevel--; } }
private void Start() { // If level type has not been set then use the editor level type if (!levelTypeSet) { SelectLevelsWithType(levelsToSelect); } // Get a list of all the ids with the given type LevelID[] ids = LevelSettings.GetAllLevelIDsOfType(levelType); // Cache the level selector button data LevelSelectorButtonData data = buttonData.Get(levelType); // Create a selector button for each ID and set it up foreach (LevelID id in ids) { LevelSelectorButton instance = Instantiate(data.prefab, data.parent.transform); instance.Setup(id); } }