void DoEntryGUI(Rect rect, SerializedProperty property)
        {
            var entryRef   = new SerializedTableEntryReference(property.FindPropertyRelative("tableEntryReference"));
            var valueLabel = new GUIContent(GetEntryLabel(entryRef.Reference, m_Collection.SharedData));

            var dropDownPosition = EditorGUI.PrefixLabel(rect, Styles.entry);

            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 EntryTreeView(assetType, m_Collection, (c, e) =>
                {
                    entryRef.Reference = e != null ? e.Id : SharedTableData.EmptyId;
                    var tableRef       = new SerializedTableReference(property.FindPropertyRelative("tableReference"));
                    tableRef.Reference = c != null ? c.TableCollectionNameReference : default(TableReference);
                    property.serializedObject.ApplyModifiedProperties();
                });
                PopupWindow.Show(dropDownPosition, new TreeViewPopupWindow(treeSelection)
                {
                    Width = dropDownPosition.width
                });
            }
        }
예제 #2
0
 public virtual void Init(SerializedProperty property)
 {
     serializedObject    = property.serializedObject;
     tableReference      = new SerializedTableReference(property.FindPropertyRelative("m_TableReference"));
     tableEntryReference = new SerializedTableEntryReference(property.FindPropertyRelative("m_TableEntryReference"));
     fallbackState       = property.FindPropertyRelative("m_FallbackState");
     NeedsInitializing   = false;
 }
        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
                });
            }
        }
예제 #4
0
            public virtual void Reset()
            {
                serializedObject    = null;
                tableReference      = null;
                tableEntryReference = null;
                fallbackState       = null;

                // Clear cached values
                m_FieldLabel              = null;
                m_SelectedEntry           = null;
                m_SelectedTableCollection = null;
                m_SelectedTableIdx        = -1;

                NeedsInitializing = true;
            }
        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
                });
            }
        }