Example #1
0
        private void EditTableLoad()
        {
            if (GUILayout.Button("Load", EditorStatics.Width_70))
            {
                if (loadTableSO != null && loadTableSO)
                {
                    if (loadTableSO.Table != null)
                    {
                        // Unsubscribe from previous table
                        if (tableSO != null && tableSO && tableSO.Table != null)
                        {
                            tableSO.Table.OnLogUpdate -= OnTableUpdate;
                        }

                        tableSO = loadTableSO;
                        tableSO.Table.OnLogUpdate += OnTableUpdate;
                        LoadTableBrowse();

                        // Clear
                        loadTableSO = null;
                        CreateLog("Loaded table: " + tableSO.Table.Name, true);
                    }
                }
            }
        }
Example #2
0
        ////////////////////////////////////////////////////////////////////////

        #region Select SO

        private void SelectTableSO()
        {
            if (currentView == CurrentView.Convert)
            {
                return;
            }

            EditorGUILayout.Space();

            GUIStyle _style = EditorStatics.GetBoxStyle(10, 10, 0, 10, 15, 15, 15, 15, 390);

            EditorGUILayout.BeginVertical(_style);

            labelDistance = EditorGUIUtility.labelWidth;
            EditorGUIUtility.labelWidth = 80;

            loadTableSO = (TableSO)EditorGUILayout.ObjectField(
                "Table SO",
                loadTableSO,
                typeof(TableSO),
                true,
                EditorStatics.Width_210
                );

            EditTableInfo();

            EditorGUIUtility.labelWidth = labelDistance;

            EditorGUILayout.Space();

            // Buttons
            EditorGUILayout.BeginHorizontal();

            EditTableLoad();

            InterfaceSave();

            // Buttons
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();
        }
Example #3
0
        ////////////////////////////////////////////////////////////////////////

        #region Convert

        private void DrawInterfaceConvert()
        {
            GUIStyle _style = EditorStatics.GetBoxStyle(10, 00, 0, 10, 15, 15, 15, 15, 350);

            EditorGUILayout.BeginVertical(_style);

            textTable = (TextAsset)EditorGUILayout.ObjectField(
                "JSON Table",
                textTable,
                typeof(TextAsset),
                true,
                EditorStatics.Width_300
                );

            importTable = (TableSO)EditorGUILayout.ObjectField(
                "Import SO",
                importTable,
                typeof(TableSO),
                true,
                EditorStatics.Width_300
                );

            if (GUILayout.Button("Import", EditorStatics.Width_70))
            {
                if (importTable == null || !importTable)
                {
                    CreateLog("Import table reference not set!", false);
                    return;
                }

                if (textTable != null && textTable)
                {
                    if (!string.IsNullOrEmpty(textTable.text))
                    {
                        try
                        {
                            Table table = JsonUtility.FromJson <Table>(textTable.text);
                            if (table != null)
                            {
                                importTable.Table = table;
                                EditorUtility.SetDirty(importTable);

                                importTable = null;
                                textTable   = null;
                                CreateLog("JSON successfully loaded into the export table SO!", true);
                            }
                        }
                        catch (System.Exception _e)
                        {
                            CreateLog("Unable to parse JSON file as a Table!", false);
                        }
                    }

                    else
                    {
                        CreateLog("JSON file contains no data!", false);
                    }
                }

                else
                {
                    CreateLog("JSON file reference not set!", false);
                }
            }

            EditorGUILayout.EndVertical();
        }