Ejemplo n.º 1
0
        public MasterBuilderEditorWindowConfig LoadOrInitializeMasterBuilderConfig()
        {
            var config = new MasterBuilderEditorWindowConfig();

            if (!Directory.Exists(ConfigDirectoryPath))
            {
                Directory.CreateDirectory(ConfigDirectoryPath);
            }

            var fileInfo = new FileInfo(ConfigFilePath);

            if (!fileInfo.Exists)
            {
                using (var writer = new StreamWriter(fileInfo.Create()))
                {
                    var json = EditorJsonUtility.ToJson(config);
                    try
                    {
                        writer.WriteLine(json);
                        writer.Close();
                    } catch (Exception e)
                    {
                        writer.Close();
                        Debug.LogError(e.StackTrace);
                    }
                }
            }
            else
            {
                using (var reader = new StreamReader(fileInfo.OpenRead()))
                {
                    try
                    {
                        var text = reader.ReadToEnd();
                        EditorJsonUtility.FromJsonOverwrite(text, config);
                    } catch (Exception e)
                    {
                        reader.Close();
                        Debug.LogError(e.StackTrace);
                    }
                }
            }

            return(config);
        }
Ejemplo n.º 2
0
        private void AddErrorLogScrollViewContent(ValidationResult result, MasterBuilderEditorWindowConfig config, Dictionary <string, Dictionary <string, string> > sheetNameDictionary)
        {
            var button = new Button();

            button.Add(new Label(result.Message));
            button.clicked += () =>
            {
                var tableProperties = sheetNameDictionary[result.Location.TableName];
                var tableGID        = tableProperties["SheetId"];

                var url = (result.Location.LocationType == RecordLocationType.SingleRecord)
                    ? GoogleSpreadSheetHelper.GetSheetUrl(config.spreadsheetID, tableGID)
                    : GoogleSpreadSheetHelper.GetSheetUrl(config.spreadsheetID, tableGID, $"{result.Location.DataIndex + 1 + 1}:{result.Location.DataIndex + 1 + 1}"); // +1 is adjust origin(0 or 1), + 1 is Columns Offset
                Application.OpenURL(url);
            };

            ErrorLogScrollView.Add(button);
        }
Ejemplo n.º 3
0
        public void SaveConfig(MasterBuilderEditorWindowConfig config)
        {
            if (!Directory.Exists(ConfigDirectoryPath))
            {
                Directory.CreateDirectory(ConfigDirectoryPath);
            }
            var fileInfo = new FileInfo(ConfigFilePath);

            using (var writer = fileInfo.Exists ? new StreamWriter(fileInfo.OpenWrite()) : new StreamWriter(fileInfo.Create()))
            {
                var json = EditorJsonUtility.ToJson(config);
                try
                {
                    writer.WriteLine(json);
                    writer.Close();
                } catch (Exception e)
                {
                    writer.Close();
                    Debug.LogError(e.StackTrace);
                }
            }
        }