void LoadConfig(string configName) { if (currentPreset == configPreset.value) { return; } currentPreset = configPreset.value; string path = configPath + configName + configExtension; if (!File.Exists(path)) { return; } ExportConfig config = JsonUtility.FromJson <ExportConfig>(File.ReadAllText(path)); LoadConfig(config); }
void LoadConfig(ExportConfig config) { string stringFormat = "0.00"; System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(""); ci.NumberFormat.NumberDecimalSeparator = "."; isLoadingconfig = true; inputFPS.text = config.targetFPS.ToString(); inputWidth.text = config.width.ToString(); SetWidth(config.width.ToString()); inputHeight.text = config.height.ToString(); SetHeight(config.height.ToString()); inputExportMode.value = (int)config.exportMode; inputOffsetX.text = config.charPosition.x.ToString(stringFormat, ci); inputOffsetY.text = config.charPosition.y.ToString(stringFormat, ci); inputScale.text = config.charScale.x.ToString(stringFormat, ci); inputScaleMode.value = (int)config.scaleMode; UpdateSpriteSize(); isLoadingconfig = false; }
public void LoadDefaultConfig(TextAsset ta) { ExportConfig config = JsonUtility.FromJson <ExportConfig>(ta.text); LoadConfig(config); SetConfigToCustom(); if (ta.name == "Atlas") { string atlasName = "Atlas "; if (characterViewer.bodyType == BodyType.Male) { atlasName += "Male"; } else { atlasName += "Female"; } for (int i = baseAnimation.options.Count; i-- > 0;) { if (baseAnimation.options[i].text == atlasName) { baseAnimation.value = i; break; } } aimAnimation.value = 0; } else if (ta.name == "Animation") { baseAnimation.value = 1; aimAnimation.value = 0; } else { baseAnimation.value = 0; aimAnimation.value = 0; } }
public void SaveConfig(string configName) { if (string.IsNullOrEmpty(configName)) { return; } ExportConfig config = new ExportConfig(); config.targetFPS = targetFPS; config.width = width; config.height = height; config.bgColor = bgColor; config.exportMode = exportMode; config.charPosition = charPosition; config.charScale = charScale; config.scaleMode = scaleMode; if (!Directory.Exists(configPath)) { Directory.CreateDirectory(configPath); } string path = configPath + configName + configExtension; string file = JsonUtility.ToJson(config); File.WriteAllText(path, file); UpdateConfigDropdown(); for (int i = 0; i < configPreset.options.Count; i++) { if (configPreset.options[i].text == configName) { currentPreset = i; configPreset.value = i; break; } } }