Esempio n. 1
0
        public static MA_TextureAtlasserProExportSettings LoadExportSettings()
        {
            string name = "MA_DefaultExportSettings";
            MA_TextureAtlasserProExportSettings _settings = AssetDatabase.LoadAssetAtPath(SETTINGS_ASSET_PATH + name + ".asset", typeof(MA_TextureAtlasserProExportSettings)) as MA_TextureAtlasserProExportSettings;

            if (_settings == null)
            {
                _settings = CreateExportSettings(name, false);
            }

            return(_settings);
        }
Esempio n. 2
0
        public static MA_TextureAtlasserProExportSettings CreateExportSettings(string name, bool canModify = true)
        {
            MA_TextureAtlasserProExportSettings _settings = ScriptableObject.CreateInstance <MA_TextureAtlasserProExportSettings>();

            _settings.canModify = canModify;

            if (_settings != null)
            {
                _settings.materialExportSettings.shader = Shader.Find("Standard");

                CreateFolder(EXPORT_ASSET_PATH);
                AssetDatabase.CreateAsset(_settings, SETTINGS_ASSET_PATH + name + ".asset");
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();

                return(_settings);
            }
            else
            {
                return(null);
            }
        }
        void OnGUI()
        {
            GUILayout.BeginArea(new Rect(MA_TextureAtlasserProUtils.VIEW_OFFSET, MA_TextureAtlasserProUtils.VIEW_OFFSET, position.width - (MA_TextureAtlasserProUtils.VIEW_OFFSET * 2), position.height - (MA_TextureAtlasserProUtils.VIEW_OFFSET * 2)));
            GUILayout.BeginVertical();

            //Input options
            settingsName = EditorGUILayout.TextField("Settings name", settingsName, GUILayout.ExpandWidth(true));
            if (settingsName == "Settings name" || string.IsNullOrEmpty(settingsName))
            {
                nameError           = true;
                GUI.backgroundColor = Color.red;
                GUILayout.Box("Error: Enter a valid settings name!", EditorStyles.helpBox);
                GUI.backgroundColor = Color.white;
            }
            else
            {
                nameError = false;
            }

            //Create
            if (!nameError)
            {
                if (GUILayout.Button("Create!", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
                {
                    MA_TextureAtlasserProExportSettings exportSettings = MA_TextureAtlasserProUtils.CreateExportSettings(settingsName, true);

                    if (curWindow != null && curWindow.textureAtlas != null)
                    {
                        curWindow.textureAtlas.exportSettings = exportSettings;
                    }

                    this.Close();
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndArea();
        }