示例#1
0
        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);
        }
示例#2
0
        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;
        }
示例#3
0
        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;
            }
        }
示例#4
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;
                }
            }
        }