コード例 #1
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();

                    DrawExportModeEditor();
                    DrawAdvancedEditor();

                    GUILayout.BeginHorizontal(EditorStyles.helpBox);

                    GUI.enabled = _selectedExportMode != ExportMode.None;
                    if (GUILayout.Button("Export", GUILayout.ExpandWidth(true), GUILayout.Height(37)))
                    {
                        if (exportObjDefault)
                        {
                            MA_TextureAtlasserProUtils.ExportAtlasMeshesObj(curWindow.textureAtlas);
                        }

                        if (_replaceMeshes)
                        {
                            MA_TextureAtlasserProUtils.ModifyMeshes(curWindow.textureAtlas);
                        }

                        if (exportPngDefault)
                        {
                            if (exportSprite)
                            {
                                MA_TextureAtlasserProUtils.ExportAtlasSpritesPNG(curWindow.textureAtlas, exportSliceSprite);
                            }
                            else
                            {
                                MA_TextureAtlasserProUtils.ExportAtlasTexturesPNG(curWindow.textureAtlas);
                            }
                        }
                    }

                    GUI.enabled = true;

                    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;
            }
        }