public override void OnGUI(Data data, Rect position, SerializedProperty property, GUIContent label) { var rowPosition = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight); var foldoutRect = new Rect(rowPosition.x, rowPosition.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); var dropDownPosition = new Rect(foldoutRect.xMax, rowPosition.y, rowPosition.width - EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight); rowPosition.MoveToNextLine(); property.isExpanded = EditorGUI.Foldout(foldoutRect, property.isExpanded, label, true); if (EditorGUI.DropdownButton(dropDownPosition, data.FieldLabel, FocusType.Passive)) { var treeSelection = new TableEntryTreeView(data.assetType, (collection, entry) => { data.SelectedTableCollection = collection as TCollection; data.SelectedTableEntry = entry; // Will be called outside of OnGUI so we need to call ApplyModifiedProperties. data.serializedObject.ApplyModifiedProperties(); }); PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection) { Width = dropDownPosition.width }); } DrawTableDetails(position, rowPosition, data, property); }
void DoTableAndEntryGUI(Rect rect, SerializedProperty property) { var tableRef = new SerializedTableReference(property.FindPropertyRelative("tableReference")); var entryRef = new SerializedTableEntryReference(property.FindPropertyRelative("tableEntryReference")); GUIContent valueLabel; if (tableRef.Reference.ReferenceType != TableReference.Type.Empty && entryRef.Reference.ReferenceType != TableEntryReference.Type.Empty) { LocalizationTableCollection collection = null; if (m_TableType == typeof(StringTable)) { collection = LocalizationEditorSettings.GetStringTableCollection(tableRef.Reference); } else { collection = LocalizationEditorSettings.GetAssetTableCollection(tableRef.Reference); } valueLabel = new GUIContent($"{GetTableLabel(tableRef.Reference)}/{GetEntryLabel(entryRef.Reference, collection?.SharedData)}"); } else { valueLabel = Styles.none; } var dropDownPosition = EditorGUI.PrefixLabel(rect, Styles.reference); if (EditorGUI.DropdownButton(dropDownPosition, valueLabel, FocusType.Passive)) { Type assetType; if (m_TableType == typeof(AssetTable)) { var assetTableCollection = m_Collection as AssetTableCollection; assetType = assetTableCollection.GetEntryAssetType(entryRef.Reference); } else { assetType = typeof(string); } var treeSelection = new TableEntryTreeView(assetType, (c, e) => { entryRef.Reference = e != null ? e.Id : SharedTableData.EmptyId; tableRef.Reference = c != null ? c.TableCollectionNameReference : default(TableReference); property.serializedObject.ApplyModifiedProperties(); }); PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection) { Width = dropDownPosition.width }); } }