Пример #1
0
        private void Save_Generation()
        {
            try {
                string rootPath = Util.GetRootPath(this);
                if (!string.IsNullOrEmpty(rootPath))
                {
                    string json    = "";
                    string keyWord = "";
                    switch (CurrentEditorMode)
                    {
                    case EditorMode.MapGenerator:
                        json    = MGConfig.ToJson();
                        keyWord = "Map";
                        break;

                    case EditorMode.CharacterGenerator:
                        json    = CGConfig.ToJson();
                        keyWord = "Character";
                        break;
                    }
                    if (!string.IsNullOrEmpty(json))
                    {
                        Util.Write(json, Util.CombinePaths(rootPath, "Data", "Current " + keyWord + " Generation Preset.json"));
                    }
                }
            } catch { };
            ShowAllAttachment.TrySave();
        }
Пример #2
0
        private void Load_Generation()
        {
            try {
                string rootPath = Util.GetRootPath(this);
                if (!string.IsNullOrEmpty(rootPath))
                {
                    string path;
                    switch (CurrentEditorMode)
                    {
                    case EditorMode.MapGenerator:
                        path = Util.CombinePaths(rootPath, "Data", "Current Map Generation Preset.json");
                        if (Util.FileExists(path))
                        {
                            MGConfig.LoadFromJson(Util.Read(path));
                            MGConfig.FixGenerationValues();
                        }
                        break;

                    case EditorMode.CharacterGenerator:
                        path = Util.CombinePaths(rootPath, "Data", "Current Character Generation Preset.json");
                        if (Util.FileExists(path))
                        {
                            CGConfig.LoadFromJson(Util.Read(path));
                            CGConfig.FixGenerationValues();
                            ReloadCharacterAttachmentThumbnailMap(true);
                        }
                        break;
                    }
                }
            } catch { };
            ShowAllAttachment.Load();
        }
Пример #3
0
        private void ImportPreset_Dialog()
        {
            try {
                string path = EditorUtility.OpenFilePanel("Import Generation Preset", "Assets", "json");
                if (!string.IsNullOrEmpty(path))
                {
                    var json = Util.Read(path);
                    if (!string.IsNullOrEmpty(json))
                    {
                        switch (CurrentEditorMode)
                        {
                        case EditorMode.MapGenerator:
                            MGConfig.LoadFromJson(json);
                            break;

                        case EditorMode.CharacterGenerator:
                            CGConfig.LoadFromJson(json);
                            ReloadCharacterAttachmentThumbnailMap(true);
                            SetDataDirty();
                            break;
                        }
                        Save_Generation();
                        Focus();
                    }
                }
            } catch (System.Exception ex) {
                Debug.LogError(ex.Message);
            }
        }
Пример #4
0
        private void ExportPreset_Dialog()
        {
            try {
                var json = "";
                switch (CurrentEditorMode)
                {
                case EditorMode.MapGenerator:
                    json = MGConfig.ToJson();
                    break;

                case EditorMode.CharacterGenerator:
                    json = CGConfig.ToJson();
                    break;
                }
                if (!string.IsNullOrEmpty(json))
                {
                    string path = EditorUtility.SaveFilePanelInProject("Export Generation Preset", "Generation Preset", "json", "");
                    if (!string.IsNullOrEmpty(path))
                    {
                        Util.Write(json, path);
                        AssetDatabase.SaveAssets();
                        AssetDatabase.Refresh();
                    }
                }
            } catch (System.Exception ex) {
                Debug.LogError(ex.Message);
            }
        }
Пример #5
0
        private void Generate()
        {
            try {
                switch (CurrentEditorMode)
                {
                case EditorMode.MapGenerator:
                    MGConfig.FixGenerationValues();
                    Data = Core_MapGeneration.Generate(MGConfig, (progress01, step) => {
                        ProgressStep(progress01, step, MAP_STEP_LABELS);
                    });
                    break;

                case EditorMode.CharacterGenerator:
                    CGConfig.FixGenerationValues();
                    Data = Core_CharacterGeneration.Generate(CGConfig, (progress01, step) => {
                        ProgressStep(progress01, step, CHARACTER_STEP_LABELS);
                    });
                    break;
                }
                SwitchModel(CurrentModelIndex, true);
                SetDataDirty();
            } catch (System.Exception ex) {
                Debug.LogWarning("[Voxel Generator] " + ex.Message);
            }
        }