private void DrawExportMenu()
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.Height(44));

            if (GUILayout.Button(MA_TextureAtlasserProGuiLoader.createExportSettingsGC, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
            {
                MA_TextureAtlasserProCreateExportWindow.InitWindow(curWindow);
            }

            bool wasEnabled = GUI.enabled;

            if (curWindow.textureAtlas.exportSettings != null)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button("Export", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
            {
                string[] textures = null;
                string   material = null;
                string[] models   = null;

                if (curWindow.textureAtlas.exportSettings.exportTextures)
                {
                    textures = MA_TextureAtlasserProUtils.ExportAtlasTextures(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.textureExportSettings);
                }

                if (curWindow.textureAtlas.exportSettings.exportMaterials)
                {
                    material = MA_TextureAtlasserProUtils.ExportAtlasMaterial(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.materialExportSettings, textures: textures);
                }

                if (curWindow.textureAtlas.exportSettings.exportModels)
                {
                    models = MA_TextureAtlasserProUtils.ExportAtlasModels(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.modelExportSettings, materialPath: material);
                }
            }

            GUI.enabled = wasEnabled;

            GUILayout.EndHorizontal();
        }
コード例 #2
0
        private void OnGUI()
        {
            if (thisWindow == null)
            {
                GetCurrentWindow();
                return;
            }

            //Get current event
            Event e = ProcessEvents();

            if (isLoaded)
            {
                GUILayout.BeginArea(new Rect(MA_TextureAtlasserProUtils.VIEWOFFSET, MA_TextureAtlasserProUtils.VIEWOFFSET, position.width - (MA_TextureAtlasserProUtils.VIEWOFFSET * 2), position.height - (MA_TextureAtlasserProUtils.VIEWOFFSET * 2)));
                GUILayout.BeginVertical();


                if (curWindow != null && curWindow.textureAtlas != null)
                {
                    //Export
                    GUILayout.BeginVertical();

                    DrawExportPresetMenu();
                    DrawExportAdvancedOptions();

                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    switch (exportPreset)
                    {
                    case ExportPreset.Custom:
                        break;

                    case ExportPreset.Default:
                        modelFormat      = ModelFormat.Obj;
                        textureFormat    = TextureFormat.Png;
                        textureType      = TextureType.Default;
                        textureScaleMode = MA_TextureUtils.TextureScaleMode.Bilinear;
                        break;

                    case ExportPreset.Sprites:
                        modelFormat      = ModelFormat.None;
                        textureFormat    = TextureFormat.Png;
                        textureType      = TextureType.SpriteSliced;
                        textureScaleMode = MA_TextureUtils.TextureScaleMode.Bilinear;
                        break;

                    case ExportPreset.ReplaceObjMeshes:
                        modelFormat      = ModelFormat.ReplaceObj;
                        textureFormat    = TextureFormat.Png;
                        textureType      = TextureType.Default;
                        textureScaleMode = MA_TextureUtils.TextureScaleMode.Bilinear;
                        break;

                    default:
                        break;
                    }

                    if (GUILayout.Button("Export", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
                    {
                        MA_TextureAtlasserProUtils.ExportAtlasModels(curWindow.textureAtlas, modelFormat);
                        MA_TextureAtlasserProUtils.ExportAtlasTextures(curWindow.textureAtlas, textureFormat, textureType, textureScaleMode);
                    }

                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }
                else if (curWindow == null)
                {
                    GUI.backgroundColor = Color.red;
                    GUILayout.Box("Error: Link with the Texture Atlas Editor lost!", EditorStyles.helpBox);
                    if (GUILayout.Button("Link Atlas Editor", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
                    {
                        curWindow = (MA_TextureAtlasserProWindow)EditorWindow.GetWindow <MA_TextureAtlasserProWindow>();
                    }
                    GUI.backgroundColor = Color.white;
                }
                else if (curWindow.textureAtlas == null)
                {
                    GUI.backgroundColor = Color.red;
                    GUILayout.Box("Error: No Texture Atlas found make sure to open one!", EditorStyles.helpBox);
                    GUI.backgroundColor = Color.white;
                }

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

            if (e.type == EventType.Repaint)
            {
                isLoaded = true;
            }
        }
        private void DrawExportMenu()
        {
            GUILayout.BeginHorizontal(EditorStyles.helpBox, GUILayout.Height(44));

            if (GUILayout.Button(MA_TextureAtlasserProIcons.createAtlasIcon, GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(true)))
            {
                MA_TextureAtlasserProCreateExportWindow.InitWindow(curWindow);
            }

            bool wasEnabled = GUI.enabled;

            if (curWindow.textureAtlas.exportSettings != null)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }

            if (GUILayout.Button("Export", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
            {
                bool export = false;

                if (curWindow.textureAtlas.exportSettings.modelExportSettings.modelFormat == ModelFormat.ReplaceMesh)
                {
                    if (EditorUtility.DisplayDialog("Replace original models?", "Are you sure you want to replace the original models, this can't be undone!", "Replace", "Cancel"))
                    {
                        export = true;
                    }
                }
                else
                {
                    export = true;
                }

                if (export)
                {
                    string[] textures = null;
                    string   material = null;
                    string[] models   = null;

                    if (curWindow.textureAtlas.exportSettings.exportTextures)
                    {
                        textures = MA_TextureAtlasserProUtils.ExportAtlasTextures(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.textureExportSettings);
                    }

                    if (curWindow.textureAtlas.exportSettings.exportMaterials)
                    {
                        material = MA_TextureAtlasserProUtils.ExportAtlasMaterial(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.materialExportSettings, textures: textures);
                    }

                    if (curWindow.textureAtlas.exportSettings.exportModels)
                    {
                        models = MA_TextureAtlasserProUtils.ExportAtlasModels(curWindow.textureAtlas, curWindow.textureAtlas.exportSettings.modelExportSettings, material: material);
                    }
                }
            }

            GUI.enabled = wasEnabled;

            GUILayout.EndHorizontal();
        }