Esempio n. 1
0
    static void OnPreviewBtn(EditorControl c)
    {     //[预览Atlas]按钮压下处理函数
        if (!UIAtlasEditorModel.GetInstance().IsProjectExist())
        { //工程未创建
            //提示创建工程Message
            EditorUtility.DisplayDialog("预览失败",
                                        "请先创建工程",
                                        "确认");
        }
        else
        {//工程已创建
            Texture2D tex = null;

            if (!UIAtlasEditorModel.GetInstance().PreViewAtlas(out tex))
            {//预览失败
                if (PROJECT_ERROR_TYPE.PROJECT_ERROR_NONE_IMAGE
                    == UIAtlasEditorModel.GetInstance().GetProjectFailedType())
                {//未添加小图
                    //提示添加小图Message
                    EditorUtility.DisplayDialog("预览失败",
                                                "请添加小图资源",
                                                "确认");
                }
            }
            else
            {//预览成功
                ClearSpriteView();

                //更新预览窗口
                UpdatePreViewWnd(tex);
            }
        }

        RequestRepaint();
    }
Esempio n. 2
0
    void OnGUI()
    {
        maxSize = new Vector2(500f, 100f);
        minSize = new Vector2(500f, 100f);

        GUILayout.Space(20f);
        GUILayout.BeginHorizontal();
        GUILayout.Label("工程名", GUILayout.Width(60f));
        m_strProjectName = GUILayout.TextField(m_strProjectName, 150, GUILayout.Width(250f));
        GUILayout.EndHorizontal();

        GUILayout.Space(10f);
        GUILayout.BeginHorizontal();

        if (GUILayout.Button("确认", GUILayout.Width(76f)))
        {
            if ((m_strProjectName != null) && (m_strProjectName != ""))
            {
                //清除现有工程
                UIAtlasEditorModel.GetInstance().ClearCurrentProject();
                //创建新工程
                UIAtlasEditorModel.GetInstance().NewPorject(m_strProjectName);

                this.Close();
            }
        }

        if (GUILayout.Button("取消", GUILayout.Width(76f)))
        {
            this.Close();
        }

        GUILayout.EndHorizontal();
    }
Esempio n. 3
0
    static private void ChangeSpriteView(int index)
    {//Inspector变更为SpriteList选择状态
        Texture2D tex        = null;
        string    SpriteName = null;

        if ((m_projTreeView == null) || (m_spriteListView == null) || (m_inspector == null) || (index < 0))
        {
            return;
        }

        //获取小图纹理
        ListCtrlItem deleteItem = m_spriteListView.Items[m_spriteListView.LastSelectItem];

        SpriteName = deleteItem.tooltip;
        tex        = UIAtlasEditorModel.GetInstance().GetSpriteImageTexture(SpriteName);
        if (tex == null)
        {
            return;
        }

        ClearProjectView();

        //更新Inspector视图至小图属性
        m_inspector.onInspector = OnSpriteInspector;

        //更新当前小图的宽、高、缩放比例信息
        UpdateSpriteSize(tex);

        //更新预览区域
        UpdatePreViewWnd(tex);

        RequestRepaint();
    }
Esempio n. 4
0
    static void OnAddImageBtn(EditorControl c)
    {     //[添加小图]按钮压下处理函数
        if (!UIAtlasEditorModel.GetInstance().IsProjectExist())
        { //工程不存在
            //提示创建工程的Message
            EditorUtility.DisplayDialog("添加失败",
                                        "请先创建工程",
                                        "确认");
        }
        else
        {//工程存在
            //初始化添加小图对话框信息
            OpenFileDialog openfiledialog1 = new OpenFileDialog();
            InitializeOpenFileDialog(openfiledialog1);

            //显示添加小图对话框
            if (openfiledialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                for (int fi = 0; fi < openfiledialog1.FileNames.Length; fi++)
                {
                    //执行添加小图命令
                    AtlasAddSpriteImageCommand cmd = new AtlasAddSpriteImageCommand();
                    cmd.m_SpriteName = openfiledialog1.FileNames[fi].ToString();
                    EditorCommandManager.GetInstance().Add(cmd);
                    m_bIsOperateSaved = false;

                    RegisterUndo("Add SpriteImage");
                }
            }

            RequestRepaint();
        }
    }
Esempio n. 5
0
    static void OnNewProjBtn(EditorControl c)
    {//[新建工程]按钮押下处理函数
        if (UIAtlasEditorModel.GetInstance().IsProjectExist())
        {
            if (!m_bIsOperateSaved)
            {
                if (EditorUtility.DisplayDialog("保存工程", "是否保存当前工程", "保存", "取消"))
                {
                    OnSaveProjBtn(c);
                }
            }
        }

        //显示新建工程对话框
        string fileNames = EditorUtility.SaveFilePanel("请选择Atlas工程的存放路径", "Assets/", "", "atlasproj");

        if (!string.IsNullOrEmpty(fileNames))
        {
            //清除现有工程
            UIAtlasEditorModel.GetInstance().ClearCurrentProject();
            //创建新工程
            UIAtlasEditorModel.GetInstance().NewPorject(fileNames);
        }

        RequestRepaint();
    }
Esempio n. 6
0
    static void OnSaveProjBtn(EditorControl c)
    {     //[保存工程]按钮压下处理函数
        if (!UIAtlasEditorModel.GetInstance().IsProjectExist())
        { //工程不存在
            //提示创建工程的Message
            EditorUtility.DisplayDialog("保存失败",
                                        "请先创建工程",
                                        "确认");
        }
        else
        {     //工程存在
            if (PROJECT_TYPE.PROJECT_TYPE_NEW == UIAtlasEditorModel.GetInstance().GetProjectType())
            { //当前是新创建的工程
                //显示选择保存工程路径对话框
                //string fileNames = EditorUtility.SaveFilePanel("", "Assets/", UIAtlasEditorModel.GetInstance().GetProjectName(), "atlasproj");
                //保存工程
                UIAtlasEditorModel.GetInstance().SaveProject("");
                //m_projTreeView.GetItemAt(0).name = Path.GetFileNameWithoutExtension("");

                RequestRepaint();
            }
            else
            {//当前是已存在工程
                //保存工程
                UIAtlasEditorModel.GetInstance().SaveProject(UIAtlasEditorModel.GetInstance().GetProjectPath());
            }

            EditorUtility.DisplayDialog("保存成功",
                                        "工程已保存至" + UIAtlasEditorModel.GetInstance().GetProjectPath(),
                                        "确认");
            m_bIsOperateSaved = true;
        }
    }
Esempio n. 7
0
    static void OnEnable(EditorRoot root)
    {//窗口有效回调函数
        UIAtlasEditorModel.GetInstance().ReadImagePathConfig();
        Undo.undoRedoPerformed += OnUndoRedo;

        RequestRepaint();
    }
Esempio n. 8
0
    static void OnAddSpriteImageCommand(bool bResult, string spriteName)
    {     //小图添加完成响应函数
        if (bResult)
        { //添加成功
            //更新小图LIst显示
            AddSpriteItem(spriteName);

            //清除SpriteList选择状态
            ClearSpriteView();

            m_bIsOperateSaved = false;
        }
        else
        {//添加失败
            if (PROJECT_ERROR_TYPE.PROJECT_ERROR_SPRITEIMAGE_PATH
                == UIAtlasEditorModel.GetInstance().GetProjectFailedType())
            {//小图路径错误
                //提示正确路径的message
                EditorUtility.DisplayDialog("添加失败",
                                            "请重新配置图库路径",
                                            "确认");
            }
            else if (PROJECT_ERROR_TYPE.PROJECT_ERROR_SPRITE_EXIST
                     == UIAtlasEditorModel.GetInstance().GetProjectFailedType())
            {//小图已存在
                //提示小图已存在的message
                EditorUtility.DisplayDialog("添加失败",
                                            Path.GetFileName(spriteName) + "已存在",
                                            "确认");
            }
        }

        RequestRepaint();
    }
Esempio n. 9
0
    static void OnMakeAtlasCommand(bool bRet)
    {//Atlas生成完响应函数
        if (bRet)
        {
            //提示生成成功
            EditorUtility.DisplayDialog("生成成功",
                                        "Atlas生成完毕\n\n" + "相关文件保存至\"" + UIAtlasEditorModel.GetInstance().GetAtlasSavePath() + "\"",
                                        "确认");
            m_bIsOperateSaved = false;
        }
        else
        {
            if (PROJECT_ERROR_TYPE.PROJECT_ERROR_ATLASOUTPU_PATH
                == UIAtlasEditorModel.GetInstance().GetProjectFailedType())
            {//未指定Atlas输出路径
                //显示选择路径对话框
                string savePath = EditorUtility.SaveFolderPanel("请选择Atlas文件的输出路径", "Assets/", "");

                if (savePath.Contains("/Assets"))
                {//路径合法(Unity相对路径)
                    //获取Unity相对路径
                    savePath = savePath.Substring(UnityEngine.Application.dataPath.Length - "Assets".Length);

                    //设定Atlas输出路径
                    UIAtlasEditorModel.GetInstance().SetAtlasSavePath(savePath + "/");

                    //执行“生成Atlas”命令
                    AtlasMakeAtlas cmd = new AtlasMakeAtlas();
                    EditorCommandManager.GetInstance().Add(cmd);

                    m_bIsOperateSaved = false;

                    RegisterUndo("Make Atlas");
                }
                else
                {
                    //提示输出路径错误message
                    EditorUtility.DisplayDialog("生成失败",
                                                "请选择Assets/下的路径",
                                                "确认");
                }
            }
            else if (PROJECT_ERROR_TYPE.PROJECT_ERROR_NONE_IMAGE
                     == UIAtlasEditorModel.GetInstance().GetProjectFailedType())
            {//未添加小图
                //提示添加小图message
                EditorUtility.DisplayDialog("生成失败",
                                            "请添加小图资源",
                                            "确认");
            }
            else
            {
                //do nothing
            }
        }

        RequestRepaint();
    }
Esempio n. 10
0
    static void OnNewProject()
    {//工程创建完成响应函数
        //添加新建工程至工程List
        AddProjectItem(UIAtlasEditorModel.GetInstance().GetProjectName());

        m_bIsOperateSaved = false;

        RequestRepaint();
    }
Esempio n. 11
0
    static void OnProjectInspector(EditorControl c, object target)
    {//工程属性视图显示
        string savePath    = null;
        string defaultPath = null;

        GUILayout.Space(20f);

        GUILayout.BeginHorizontal();

        GUILayout.Label("Atlas输出路径", GUILayout.Width(80f));

        GUI.SetNextControlName("Atlas输出路径");
        m_projOutputPath = EditorGUILayout.TextField(m_projOutputPath, GUILayout.Width(150));

        if (GUILayout.Button("配置路径"))
        {
            defaultPath = (UIAtlasEditorModel.GetInstance().GetAtlasSavePath() == null) ? "Assets/" : UIAtlasEditorModel.GetInstance().GetAtlasSavePath();
            savePath    = EditorUtility.SaveFolderPanel("请选择Atlas文件的输出路径", defaultPath, "");

            if (savePath.Contains("/Assets"))
            {//路径合法(Unity相对路径)
                //获取Unity相对路径
                savePath = savePath.Substring(UnityEngine.Application.dataPath.Length - "Assets".Length);

                //设定Atlas输出路径
                UIAtlasEditorModel.GetInstance().SetAtlasSavePath(savePath + "/");

                m_projOutputPath = savePath + "/";

                m_bIsOperateSaved = false;
            }
            else
            {
                //提示输出路径错误message
                EditorUtility.DisplayDialog("生成失败",
                                            "请选择Assets/下的路径",
                                            "确认");
            }
        }

        //编辑完成
        if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.Used)
        {
            if (GUI.GetNameOfFocusedControl() == "Atlas输出路径")
            {
                //更新Atlas输出路径
                UIAtlasEditorModel.GetInstance().SetAtlasSavePath(m_projOutputPath);

                m_bIsOperateSaved = false;
            }
        }

        GUILayout.EndHorizontal();

        RequestRepaint();
    }
Esempio n. 12
0
    static private void AddSpriteItem(string spriteName)
    {//添加SpriteList Item
        if ((m_spriteListView == null) || (spriteName == null))
        {
            return;
        }

        ListCtrlItem newItem = new ListCtrlItem();

        newItem.name          = Path.GetFileName(spriteName);
        newItem.image         = UIAtlasEditorModel.GetInstance().GetSpriteZoomTexture(spriteName);
        newItem.tooltip       = spriteName;
        newItem.color         = Color.white;
        newItem.onSelectColor = Color.blue;
        m_spriteListView.AddItem(newItem);

        //m_bIsOperateSaved = false;
    }
Esempio n. 13
0
    static private void ChangeProjectView()
    {//Inspector变更至工程List 选择状态
        if ((m_spriteListView == null) || (m_inspector == null))
        {
            return;
        }

        //更新Inspector视图至工程属性
        m_inspector.onInspector = OnProjectInspector;
        m_projOutputPath        = UIAtlasEditorModel.GetInstance().GetAtlasSavePath();

        //清空预览区域
        GameObject.DestroyImmediate(m_previewObj);

        //初始化小图List选择状态
        m_spriteListView.LastSelectItem = -1;

        RequestRepaint();
    }
Esempio n. 14
0
    static void OnDisable(EditorRoot root)
    {//窗口无效回调函数
        if (UIAtlasEditorModel.GetInstance().IsProjectExist())
        {
            if (!m_bIsOperateSaved)
            {
                if (EditorUtility.DisplayDialog("保存工程", "是否保存当前工程", "保存", "取消"))
                {
                    OnSaveProjBtn(null);
                }
            }
        }

        UIAtlasTempTextureManager.DestroyInstance();
        UIAtlasEditorModel.GetInstance().DestoryInstance();
        EditorCommandManager.GetInstance().Clear();
        Undo.undoRedoPerformed -= OnUndoRedo;
        GameObject.DestroyImmediate(m_Counter);
        GameObject.DestroyImmediate(m_previewObj);
    }
Esempio n. 15
0
    static void OnMakeAtlasBtn(EditorControl c)
    {     //[生成Atlas]按钮压下处理函数
        if (!UIAtlasEditorModel.GetInstance().IsProjectExist())
        { //工程未创建
            //提示创建工程message
            EditorUtility.DisplayDialog("生成失败",
                                        "请先创建工程",
                                        "确认");
        }
        else
        {//工程已存在
            AtlasMakeAtlas cmd = new AtlasMakeAtlas();
            EditorCommandManager.GetInstance().Add(cmd);
            m_bIsOperateSaved = false;

            RegisterUndo("Make Atlas");
        }

        RequestRepaint();
    }
Esempio n. 16
0
    static void OnConfigImageBaseBtn(EditorControl c)
    {//[配置小图路径]按钮压下处理函数
        string defaultPath = UIAtlasEditorModel.GetInstance().ReadImagePathConfig();
        //显示保存路径对话框
        string savePath = EditorUtility.SaveFolderPanel("请选择图库路径", defaultPath, "");

        //将路径写入配置文件
        if ((savePath != "") && (savePath != null))
        {
            if (savePath.EndsWith(":/"))
            {
                UIAtlasEditorModel.GetInstance().WriteImagePathConfig(savePath);
            }
            else
            {
                UIAtlasEditorModel.GetInstance().WriteImagePathConfig(savePath + "/");
            }

            m_bIsOperateSaved = false;
        }
    }
Esempio n. 17
0
    static void OnOpenProjBtn(EditorControl c)
    {//[打开工程]按钮压下处理函数
        if (UIAtlasEditorModel.GetInstance().IsProjectExist())
        {
            if (!m_bIsOperateSaved)
            {
                if (EditorUtility.DisplayDialog("保存工程", "是否保存当前工程", "保存", "取消"))
                {
                    OnSaveProjBtn(c);
                }
            }
        }

        string defaultDir  = string.Empty;
        string defaultPath = UIAtlasEditorModel.GetInstance().ReadRecentOpenProjectPath();

        if (!string.IsNullOrEmpty(defaultPath))
        {
            defaultDir = Path.GetDirectoryName(defaultPath);
        }
        //显示打开工程对话框
        string path = EditorUtility.OpenFilePanel("请选择将要打开的Atlas工程文件", defaultDir, "atlasproj");

        if ((path != null) && (path != ""))
        {
            //读取工程
            if (UIAtlasEditorModel.GetInstance().LoadProject(path))
            {//读取成功
                //向工程List中添加新的工程项目
                AddProjectItem(UIAtlasEditorModel.GetInstance().GetProjectName());

                //更新Inspector视图至工程属性
                m_projOutputPath = UIAtlasEditorModel.GetInstance().GetAtlasSavePath();

                RequestRepaint();
            }
        }
    }
Esempio n. 18
0
    static void OnSpriteImageZoomChangedCommand(string spritePath)
    {//小图缩放比例变更完成响应函数
        if ((m_spriteListView == null) || (m_inspector == null))
        {
            return;
        }

        //获取小图纹理
        Texture2D tex = null;

        tex = UIAtlasEditorModel.GetInstance().GetSpriteZoomTexture(spritePath);
        if (tex == null)
        {
            return;
        }

        //更新小图尺寸
        UpdateSpriteSize(tex);

        //更新Sprite List选择Index
        for (int i = 0; i < m_spriteListView.GetItemCount(); i++)
        {
            if (m_spriteListView.Items[i].tooltip == spritePath)
            {
                m_spriteListView.LastSelectItem = i;
            }
        }

        //更新Sprite List选中状态
        m_inspector.onInspector = OnSpriteInspector;

        m_bIsOperateSaved = false;

        //更新预览窗口
        UpdatePreViewWnd(tex);
    }
Esempio n. 19
0
 public void UnExecute()
 {
     UIAtlasEditorModel.GetInstance().DeleteAtlas();
 }
Esempio n. 20
0
 public void Execute()
 {
     UIAtlasEditorModel.GetInstance().MakeAtlas();
 }
Esempio n. 21
0
 public void UnExecute()
 {
     UIAtlasEditorModel.GetInstance().AddSpriteImage(m_SpriteName);
 }
Esempio n. 22
0
 public void Execute()
 {
     UIAtlasEditorModel.GetInstance().RemoveSpriteImage(m_SpriteName);
 }
Esempio n. 23
0
 public void UnExecute()
 {
     UIAtlasEditorModel.GetInstance().ZoomSpriteImage(m_SpriteName, m_oldScaleFactor);
 }
Esempio n. 24
0
    static void OnSpriteInspector(EditorControl c, object target)
    {//小图属性窗口显示
        int    w, h;
        string oldStr     = null;
        string SpriteName = null;

        if ((m_spriteListView == null) || (m_spriteListView.LastSelectItem < 0))
        {
            return;
        }

        ListCtrlItem deleteItem = m_spriteListView.Items[m_spriteListView.LastSelectItem];

        SpriteName = deleteItem.tooltip;

        GUILayout.Space(20f);

        GUILayout.BeginHorizontal();
        GUILayout.Label("宽高比", GUILayout.Width(60f));
        GUILayout.TextField(m_aspecet.ToString(), GUILayout.Width(150));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("宽度", GUILayout.Width(60f));
        GUI.SetNextControlName("宽度");
        oldStr           = m_spriteWidthStr;
        m_spriteWidthStr = GUILayout.TextField(m_spriteWidthStr, GUILayout.Width(150));
        if ((GUI.GetNameOfFocusedControl() == "宽度") && (oldStr != m_spriteWidthStr))
        {
            int.TryParse(m_spriteWidthStr, out w);
            h = (int)(w / m_aspecet);
            m_spriteHeightStr = h.ToString();
        }
        GUILayout.Label("pix", GUILayout.Width(50f));
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("高度", GUILayout.Width(60f));
        GUI.SetNextControlName("高度");
        oldStr            = m_spriteHeightStr;
        m_spriteHeightStr = GUILayout.TextField(m_spriteHeightStr, GUILayout.Width(150));
        if ((GUI.GetNameOfFocusedControl() == "高度") && (oldStr != m_spriteHeightStr))
        {
            int.TryParse(m_spriteHeightStr, out h);
            w = (int)(h * m_aspecet);
            m_spriteWidthStr = w.ToString();
        }
        GUILayout.Label("pix", GUILayout.Width(50f));
        GUILayout.EndHorizontal();

        if (Event.current.keyCode == KeyCode.Return && Event.current.type == EventType.Used)
        {
            if (GUI.GetNameOfFocusedControl() == "高度" || GUI.GetNameOfFocusedControl() == "宽度")
            {
                AtlasSpriteImage      spriteImage = null;
                AtlasImageZoomCommand cmd         = null;
                Texture2D             tex         = null;

                int.TryParse(m_spriteWidthStr, out w);
                int.TryParse(m_spriteHeightStr, out h);

                cmd = new AtlasImageZoomCommand();
                UIAtlasEditorModel.GetInstance().GetSpriteImage(SpriteName, out spriteImage);
                tex = UIAtlasEditorModel.GetInstance().GetSpriteTexture(SpriteName);
                if (tex == null)
                {
                    return;
                }

                cmd.m_oldScaleFactor = spriteImage.ZoomScale;
                cmd.m_newScaleFactor = (float)w / (float)tex.width;
                cmd.m_SpriteName     = SpriteName;
                EditorCommandManager.GetInstance().Add(cmd);

                m_bIsOperateSaved = false;

                RegisterUndo("Zoom Image");
            }
        }

        //RequestRepaint();
    }
Esempio n. 25
0
    public static void InitControls(EditorRoot editorRoot)
    {//初始化窗口
        if (editorRoot == null)
        {
            //提示程序错误Message
            EditorUtility.DisplayDialog("运行错误",
                                        "窗口初始化失败",
                                        "确认");
            return;
        }

        s_root = editorRoot;
        //s_root.position = new Rect(100f, 100f, 1280, 768f);

        {
            s_root.onEnable  = OnEnable;
            s_root.onDisable = OnDisable;
        }

        #region 创建布置窗口元素

        #region 第一级分割
        Rect btnRect   = new Rect(0, 0, 80, 20);
        Rect labelRect = new Rect(0, 0, 80, 5);
        Rect hboxRect  = new Rect(0, 0, 300, 5);

        HSpliterCtrl hs1 = new HSpliterCtrl();
        hs1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);
        HSpliterCtrl hs2 = new HSpliterCtrl();
        hs2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);

        HBoxCtrl hb1 = new HBoxCtrl();      //布置上方菜单条
        HBoxCtrl hb2 = new HBoxCtrl();      //布置主窗口
        HBoxCtrl hb3 = new HBoxCtrl();      //布置下方状态栏
        #endregion

        #region 第二级分割
        VSpliterCtrl vs2_1 = new VSpliterCtrl();
        vs2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f);
        vs2_1.Dragable         = true;
        VSpliterCtrl vs2_2 = new VSpliterCtrl();
        vs2_2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f, true);
        vs2_2.Dragable         = true;

        VBoxCtrl vb2_1 = new VBoxCtrl();               //布置工程目录/小图列表
        VBoxCtrl vb2_2 = new VBoxCtrl();               //布置预览窗口
        VBoxCtrl vb2_3 = new VBoxCtrl();               //布置Inspector窗口
        #endregion

        #region 第三级分割
        HSpliterCtrl hs2_1_1 = new HSpliterCtrl();
        hs2_1_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(260f, true);

        VBoxCtrl vb2_1_1 = new VBoxCtrl();                    //布置小图列表
        VBoxCtrl vb2_1_2 = new VBoxCtrl();                    //布置工程目录
        #endregion

        #region  第四级分割
        HSpliterCtrl hs2_1_2_1 = new HSpliterCtrl();
        hs2_1_2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(240, true);

        VBoxCtrl vb2_1_2_1 = new VBoxCtrl();                    //布置小图列表
        VBoxCtrl vb2_1_2_2 = new VBoxCtrl();                    //布置工程目录
        #endregion
        #endregion

        #region 布置窗口(由高至低布置)

        #region 第四级分割

        #region Project View
        HBoxCtrl projectBtnBox = new HBoxCtrl();
        projectBtnBox.Size = hboxRect;

        LabelCtrl procLabel = new LabelCtrl();
        procLabel.Size    = labelRect;
        procLabel.Caption = "Project View";

        ButtonCtrl newProjBtn = new ButtonCtrl();
        newProjBtn.Caption = "新建工程";
        newProjBtn.Name    = "_NewProjBtn";
        newProjBtn.Size    = btnRect;
        newProjBtn.onClick = OnNewProjBtn;

        ButtonCtrl openProjBtn = new ButtonCtrl();
        openProjBtn.Caption = "打开工程";
        openProjBtn.Name    = "_OpenProjBtn";
        openProjBtn.Size    = btnRect;
        openProjBtn.onClick = OnOpenProjBtn;

        ButtonCtrl saveProjBtn = new ButtonCtrl();
        saveProjBtn.Caption = "保存工程";
        saveProjBtn.Name    = "_SaveProjBtn";
        saveProjBtn.Size    = btnRect;
        saveProjBtn.onClick = OnSaveProjBtn;
        projectBtnBox.Add(newProjBtn);
        projectBtnBox.Add(saveProjBtn);
        projectBtnBox.Add(openProjBtn);

        // vb2_1_2_1.Add(procLabel);
        vb2_1_2_1.Add(projectBtnBox);
        #endregion

        m_projTreeView                = new ListViewCtrl(); //工程目录
        m_projTreeView.Caption        = "Project";
        m_projTreeView.Name           = "Project";
        m_projTreeView.onItemSelected = OnSelectProjectListItem;
        m_projTreeView.IsTextureView  = false;


        vb2_1_2_2.Add(m_projTreeView);

        hs2_1_2_1.Add(vb2_1_2_1);
        hs2_1_2_1.Add(vb2_1_2_2);
        #endregion

        #region 第三级分割
        m_spriteListView = new ListViewCtrl();        //小图列表
        m_spriteListView.IsTextureView = false;
        m_spriteListView.Caption       = "小图";
        m_spriteListView.Name          = "spriteTreeView";

        m_spriteListView.onItemSelected     = OnSelectListItem;
        m_spriteListView.onItemCtrlSelected = OnSelectListItem;
        m_spriteListView.onItemSelectedR    = OnSelectListItemR;
        m_spriteListView.onItemSelectedRU   = OnSelectListItemRU;
        vb2_1_1.Add(m_spriteListView);
        vb2_1_2.Add(hs2_1_2_1);

        hs2_1_1.Add(vb2_1_1);
        hs2_1_1.Add(vb2_1_2);
        #endregion

        #region 第二级分割
        m_preview          = new MainViewCtrl();     //预览窗口
        m_preview.Name     = "_Preview";
        m_preview.bkColor  = Color.grey;
        m_preview.Is2DView = true;

        m_inspector             = new InspectorViewCtrl(); //属性窗口
        m_inspector.Name        = "_Inspector";
        m_inspector.onInspector = null;

        vb2_1.Add(hs2_1_1);
        vb2_2.Add(m_preview);
        vb2_3.Add(m_inspector);

        vs2_1.Add(vb2_1);
        vs2_1.Add(vs2_2);

        vs2_2.Add(m_preview);
        vs2_2.Add(vb2_3);
        #endregion

        #region 第一级分割
        #region  方菜单条
        ButtonCtrl addImageBtn = new ButtonCtrl();
        addImageBtn.Caption = "添加小图";
        addImageBtn.Name    = "_AddImageBtn";
        addImageBtn.Size    = btnRect;
        addImageBtn.onClick = OnAddImageBtn;

        ButtonCtrl previewBtn = new ButtonCtrl();
        previewBtn.Caption = "生成预览";
        previewBtn.Name    = "_PreviewBtn";
        previewBtn.Size    = btnRect;
        previewBtn.onClick = OnPreviewBtn;

        ButtonCtrl makeAtlasBtn = new ButtonCtrl();
        makeAtlasBtn.Caption = "生成图集";
        makeAtlasBtn.Name    = "_MakeAtlasBtn";
        makeAtlasBtn.Size    = btnRect;
        makeAtlasBtn.onClick = OnMakeAtlasBtn;

        ButtonCtrl configImageBaseBtn = new ButtonCtrl();
        configImageBaseBtn.Caption = "配置图库路径";
        configImageBaseBtn.Name    = "_ConfigImageBaseBtn";
        configImageBaseBtn.Size    = btnRect;
        configImageBaseBtn.onClick = OnConfigImageBaseBtn;

        ButtonCtrl helpBtn = new ButtonCtrl();
        helpBtn.Caption  = "帮助";
        helpBtn.Size     = btnRect;
        helpBtn.onClick += OnHelp;

        hb1.Add(addImageBtn);
        hb1.Add(previewBtn);
        hb1.Add(makeAtlasBtn);
        hb1.Add(configImageBaseBtn);
        hb1.Add(helpBtn);
        #endregion

        hb2.Add(vs2_1);

        hs1.Add(hb1);
        hs1.Add(hs2);

        hs2.Add(hb2);
        hs2.Add(hb3);
        #endregion

        #endregion

        //设置窗口根控件
        s_root.RootCtrl = hs1;

        //注册UIAtlasEditorModel回调函数
        UIAtlasEditorModel.GetInstance().onNewProject          = OnNewProject;
        UIAtlasEditorModel.GetInstance().onSpriteImageLoad     = OnSpriteImageLoad;
        UIAtlasEditorModel.GetInstance().onClearCurrentProject = OnClearCurrentProject;

        UIAtlasEditorModel.GetInstance().onAddSpriteImageCommand    = OnAddSpriteImageCommand;
        UIAtlasEditorModel.GetInstance().onDeleteSpriteImageCommand = OnDeleteSpriteImageCommand;
        UIAtlasEditorModel.GetInstance().onMakeAtlasCommand         = OnMakeAtlasCommand;
        UIAtlasEditorModel.GetInstance().onSpriteZoomChangedCommand = OnSpriteImageZoomChangedCommand;

        //注册编辑器窗口OnGui回调函数
        s_root.onGUI        = OnEditorGUI;
        m_Counter           = new GameObject();
        m_Counter.name      = "AtlasCmdCounter";
        m_Counter.hideFlags = HideFlags.HideAndDontSave;
        m_Counter.AddComponent <UIAtlasCommandCounter>();
        m_CommandCounter = m_Counter.GetComponent <UIAtlasCommandCounter>();
    }