private void DrawItem(int index) { CollectableScriptableObject collectionItem = filteredItemList[index]; using (new EditorGUILayout.VerticalScope("Box")) { using (new EditorGUILayout.HorizontalScope()) { CollectionUtility.SetFoldoutOpen(collectionItem, EditorGUILayout.Toggle(GUIContent.none, CollectionUtility.IsFoldoutOpen(collectionItem), EditorStyles.foldout, GUILayout.Width(13))); using (EditorGUI.ChangeCheckScope changeCheck = new EditorGUI.ChangeCheckScope()) { string newName = EditorGUILayout.DelayedTextField(collectionItem.name, CollectionEditorGUI.ItemNameStyle, GUILayout.ExpandWidth(true)); if (changeCheck.changed) { AssetDatabaseUtils.RenameAsset(collectionItem, newName); } } DrawSelectItem(collectionItem); DrawMoveItemDownButton(collectionItem); DrawMoveItemUpButton(collectionItem); DrawDeleteButton(collectionItem); } if (CollectionUtility.IsFoldoutOpen(collectionItem)) { EditorGUI.indentLevel++; Editor editor = CollectionUtility.GetEditorForItem(collectionItem); using (EditorGUI.ChangeCheckScope changeCheck = new EditorGUI.ChangeCheckScope()) { GUILayout.Space(10); editor.OnInspectorGUI(); EditorGUILayout.Space(); if (changeCheck.changed) { if (index > filteredSerializedList.Count - 1 || filteredSerializedList[index] == null) { filteredItemListDirty = true; } else { filteredSerializedList[index].ApplyModifiedProperties(); } } } EditorGUI.indentLevel--; } } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { Initialize(property); collectableItem = property.objectReferenceValue as CollectableScriptableObject; if (optionsAttribute.DrawType == DrawType.AsReference) { EditorGUI.PropertyField(position, property, label, true); return; } Rect popupRect = position; popupRect.height = 15; if (collectableItem != null) { DrawEditFoldoutButton(ref popupRect); DrawGotoButton(collection, ref popupRect); } using (new EditorGUI.PropertyScope(position, label, property)) { popupRect = EditorGUI.PrefixLabel(popupRect, label); int indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; bool showMixedValue = EditorGUI.showMixedValue; switch (optionsAttribute.DrawType) { case DrawType.Dropdown: { EditorGUI.showMixedValue = property.hasMultipleDifferentValues; DrawDropDown(popupRect, property); break; } default: throw new ArgumentOutOfRangeException("DrawType: " + optionsAttribute.DrawType); } if (collectableItem != null) { if (CollectionUtility.IsFoldoutOpen(foldoutObject)) { EditorGUI.indentLevel++; using (new EditorGUILayout.VerticalScope("Box")) { Editor editor = CollectionUtility.GetEditorForItem(collectableItem); using (EditorGUI.ChangeCheckScope changedCheck = new EditorGUI.ChangeCheckScope()) { GUILayout.Space(10); using (new EditorGUILayout.VerticalScope()) { editor.OnInspectorGUI(); } EditorGUILayout.Space(); if (changedCheck.changed) { property.serializedObject.ApplyModifiedProperties(); } } } EditorGUI.indentLevel--; } } EditorGUI.showMixedValue = showMixedValue; EditorGUI.indentLevel = indent; } }