public override void OnGUI(LocalizedTablePropertyDrawerPropertyData data, Rect position, SerializedProperty property, GUIContent label) { var dropDownPosition = EditorGUI.PrefixLabel(position, label); if (EditorGUI.DropdownButton(dropDownPosition, data.FieldLabel, FocusType.Passive)) { var treeSelection = new TableTreeView(typeof(TCollection) == typeof(StringTableCollection) ? typeof(StringTable) : typeof(AssetTable), collection => { data.SelectedTableCollection = collection as TCollection; // Will be called outside of OnGUI so we need to call ApplyModifiedProperties. data.serializedObject.ApplyModifiedProperties(); }); PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection) { Width = dropDownPosition.width }); } }
void DoTableGUI(Rect rect, SerializedProperty property) { var tableRef = new SerializedTableReference(property.FindPropertyRelative("tableReference")); var valueLabel = new GUIContent(GetTableLabel(tableRef.Reference)); var dropDownPosition = EditorGUI.PrefixLabel(rect, Styles.tableCollection); if (EditorGUI.DropdownButton(dropDownPosition, valueLabel, FocusType.Passive)) { var treeSelection = new TableTreeView(m_TableType, sel => { tableRef.Reference = sel != null ? sel.TableCollectionNameReference : default(TableReference); var entryRef = new SerializedTableEntryReference(property.FindPropertyRelative("tableEntryReference")); entryRef.Reference = SharedTableData.EmptyId; property.serializedObject.ApplyModifiedProperties(); }); PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection) { Width = dropDownPosition.width }); } }