Esempio n. 1
0
        void DrawLooseTableGUI()
        {
            if (m_TargetTable.SharedData == null)
            {
                EditorGUILayout.HelpBox("Shared Table Data is missing. Please add the missing asset or create a new one.", MessageType.Error);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.ObjectField(m_SharedTableData);
                if (EditorGUI.EndChangeCheck())
                {
                    ResolveTableCollection();
                }
                return;
            }

            EditorGUILayout.HelpBox("Table does not belong to a Collection and will be ignored.", MessageType.Warning);
            if (m_SharedTableDataCollection != null)
            {
                if (GUILayout.Button(Styles.addToCollection))
                {
                    m_SharedTableDataCollection.AddTable(m_TargetTable, createUndo: true);
                }
                return;
            }

            if (m_PossibleTableCollection.Count > 0)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox("The following loose tables could be combined into a new Table Collection", MessageType.Info);
                for (int i = 0; i < m_PossibleTableCollection.Count; ++i)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button(m_PossibleTableCollection[i].name, EditorStyles.label))
                    {
                        EditorGUIUtility.PingObject(m_PossibleTableCollection[i]);
                    }
                    if (GUILayout.Button(Styles.removeTableFromList, GUILayout.Width(40)))
                    {
                        m_PossibleTableCollection.RemoveAt(i);
                        EditorGUIUtility.ExitGUI();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (m_PossibleTableCollection.Count > 0)
            {
                var isStringTable = typeof(StringTable).IsAssignableFrom(m_PossibleTableCollection[0].GetType());
                var label         = isStringTable ? Styles.createStringTableCollection : Styles.createAssetTableCollection;
                if (GUILayout.Button(label))
                {
                    var defaultDirectory = Path.GetDirectoryName(AssetDatabase.GetAssetPath(m_TargetTable.SharedData));
                    var path             = EditorUtility.SaveFilePanel("Create Table Collection", defaultDirectory, m_TargetTable.TableCollectionName, "asset");
                    if (string.IsNullOrEmpty(path))
                    {
                        return;
                    }
                    LocalizationEditorSettings.CreateCollectionFromLooseTables(m_PossibleTableCollection, path);
                }
            }
        }
Esempio n. 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (m_Collection.SharedData == null)
            {
                EditorGUILayout.HelpBox(Styles.missingSharedTableData, MessageType.Error);
                EditorGUI.BeginChangeCheck();
                EditorGUILayout.PropertyField(m_SharedTableData);
                if (EditorGUI.EndChangeCheck())
                {
                    RefreshTables();
                }
                return;
            }

            m_Tables.isExpanded = EditorGUILayout.Foldout(m_Tables.isExpanded, Styles.tables, true);
            if (m_Tables.isExpanded)
            {
                EditorGUI.indentLevel++;
                var tables = m_Collection.Tables;
                for (int i = 0; i < tables.Count; ++i)
                {
                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button(tables[i].asset?.name, EditorStyles.label))
                    {
                        EditorGUIUtility.PingObject(tables[i].asset);
                    }

                    if (GUILayout.Button(Styles.removeTable, GUILayout.Width(60)))
                    {
                        m_Collection.RemoveTable(tables[i].asset, createUndo: true);
                        GUIUtility.ExitGUI();
                    }

                    EditorGUILayout.EndHorizontal();
                }
                EditorGUI.indentLevel--;
            }

            // Loose tables
            if (m_LooseTables.Count > 0)
            {
                m_ShowLooseTables = EditorGUILayout.Foldout(m_ShowLooseTables, Styles.looseTables);
                if (m_ShowLooseTables)
                {
                    EditorGUILayout.HelpBox(Styles.looseTablesInfo);
                    EditorGUI.indentLevel++;
                    for (int i = 0; i < m_LooseTables.Count; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button(m_LooseTables[i].name, EditorStyles.label))
                        {
                            EditorGUIUtility.PingObject(m_LooseTables[i]);
                        }

                        if (GUILayout.Button(Styles.addTable, GUILayout.Width(50)))
                        {
                            m_Collection.AddTable(m_LooseTables[i], createUndo: true);
                            GUIUtility.ExitGUI();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;
                }
            }

            // Missing tables
            if (m_MissingTables.Count > 0)
            {
                m_ShowMissingTables = EditorGUILayout.Foldout(m_ShowMissingTables, Styles.missingTables);
                if (m_ShowMissingTables)
                {
                    EditorGUILayout.HelpBox(Styles.missingTablesInfo);
                    EditorGUI.indentLevel++;
                    for (int i = 0; i < m_MissingTables.Count; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        if (GUILayout.Button(m_MissingTables[i].name, EditorStyles.label))
                        {
                            EditorGUIUtility.PingObject(m_MissingTables[i]);
                        }

                        if (GUILayout.Button(Styles.createTable, GUILayout.Width(60)))
                        {
                            m_Collection.AddNewTable(m_MissingTables[i].Identifier);
                            GUIUtility.ExitGUI();
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    EditorGUI.indentLevel--;
                }
            }

            if (GUILayout.Button(Styles.editCollection))
            {
                LocalizationTablesWindow.ShowWindow(target as LocalizationTableCollection);
            }

            EditorGUILayout.PropertyField(m_Group, Styles.group);

            m_ExtensionsList.DoLayoutList();
            serializedObject.ApplyModifiedProperties();
        }