Пример #1
0
    public static void InitControls(EditorRoot editorRoot)
    {
        s_root = editorRoot;

        //s_root.position = new Rect(100f, 100f, 1024, 768f);
        s_root.onDestroy = OnDestroy;
        s_root.onEnable  = OnEnable;

        Rect btnRect      = new Rect(0, 0, 80, 20);
        Rect comboBoxRect = new Rect(0, 0, 100, 20);

        //Modify by liteng for 发布工具改善Start
        #region 创建布置窗口元素
        #region 第一级
        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;

        VBoxCtrl vb2_1 = new VBoxCtrl();               //资源视图
        VBoxCtrl vb2_2 = new VBoxCtrl();               //发布信息视图
        #endregion
        #endregion

        #region 布置窗口(由高至低布置)
        #region 第二级
        TreeViewCtrl m_treeView = new TreeViewCtrl();   //资源列表
        m_treeView.Name          = "_MainTreeView";
        m_treeView.onValueChange = OnTreeViewNodeToggle;

        InspectorViewCtrl m_inspector = new InspectorViewCtrl();  //发布信息视图
        m_inspector.Name        = "_Inspector";
        m_inspector.onInspector = OnInspector;

        vb2_1.Add(m_treeView);
        vb2_2.Add(m_inspector);
        vs2_1.Add(vb2_1);
        vs2_1.Add(vb2_2);

        hb2.Add(vs2_1);
        #endregion

        #region 第一级
        //[导出]按钮
        ButtonCtrl exportBtn = new ButtonCtrl();
        exportBtn.Caption = "导出";
        exportBtn.Name    = "_ExportButton";
        exportBtn.Size    = btnRect;
        exportBtn.onClick = OnExportBtnClick;

        //[发布]按钮
        //ButtonCtrl publishBtn = new ButtonCtrl();
        //publishBtn.Caption = "发布";
        //publishBtn.Name = "_PublishButton";
        //publishBtn.Size = btnRect;
        //publishBtn.onClick = OnPublishBtnClick;


        //[配置AB路径]按钮
        //ButtonCtrl configPublishBtn = new ButtonCtrl();
        //configPublishBtn.Caption = "配置AB路径";
        //configPublishBtn.Name = "_ConfigPublishButton";
        //configPublishBtn.Size = btnRect;
        //configPublishBtn.onClick = OnConfigPublishPathBtnClick;

        //版本下拉菜单
        ComboBoxCtrl <int> debugCombo = new ComboBoxCtrl <int>(0);
        debugCombo.Size          = comboBoxRect;
        debugCombo.Name          = "_DebugCombo";
        debugCombo.onValueChange = OnDebugComboSelect;
        debugCombo.AddItem(new ComboItem("Debug", 0));
        debugCombo.AddItem(new ComboItem("Release", 1));

        hb1.Add(exportBtn);
        //hb1.Add(publishBtn);
        //hb1.Add(configPublishBtn);
        hb1.Add(debugCombo);

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


        #endregion
        s_root.RootCtrl = hs1;

        UpdateDebugCombobox();
        PackageExportToolModel.GetInstance().onExportComplete = OnExportComplete;
        //Modify by liteng for 发布工具改善 end

        #region 原有代码
        //HSpliterCtrl hspliter = new HSpliterCtrl();
        //hspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);

        //上方树状视图
        //VBoxCtrl vb0 = new VBoxCtrl();
        //hspliter.Add(vb0);

        ////下方工具条
        //HBoxCtrl hb0 = new HBoxCtrl();
        //hspliter.Add(hb0);

        //TreeViewCtrl treeView = new TreeViewCtrl();
        //treeView.Name = "_MainTreeView";
        //vb0.Add(treeView);

        //TextBoxCtrl tbVersion = new TextBoxCtrl();
        //tbVersion.Size = new Rect(0, 0, 30, 20);
        //tbVersion.Name = "_VersionBox";
        //tbVersion.Caption = "版本号";
        //tbVersion.Enable = true;
        //tbVersion.layoutConstraint = LayoutConstraint.GetInspectorViewConstraint(10, 50);

        //TextBoxCtrl tbFileName = new TextBoxCtrl();
        //tbFileName.Size = new Rect(0, 0, 60, 20);
        //tbFileName.Name = "_SaveFileName";
        //tbFileName.Caption = "输出文件";
        //tbFileName.Enable = true;
        //tbFileName.layoutConstraint = LayoutConstraint.GetInspectorViewConstraint(10, 50);

        //Rect btnRect = new Rect(0, 0, 60, 20);

        //ButtonCtrl ChooseFileBtn = new ButtonCtrl();
        //ChooseFileBtn.Caption = "选择";
        //ChooseFileBtn.Name = "_ChooseFileName";
        //ChooseFileBtn.Size = btnRect;
        //ChooseFileBtn.onClick = OnChooseFileNameButtonClick;

        //ButtonCtrl okBtn = new ButtonCtrl();
        //okBtn.Caption = "确定";
        //okBtn.Name = "_OkButton";
        //okBtn.Size = btnRect;
        //okBtn.onClick = OnOkButtonClick;

        //ButtonCtrl cancelBtn = new ButtonCtrl();
        //cancelBtn.Caption = "取消";
        //cancelBtn.Name = "_CancelButton";
        //cancelBtn.Size = btnRect;
        //cancelBtn.onClick = OnCancelButtonClick;

        //hb0.Add(tbVersion);
        //hb0.Add(tbFileName);
        //hb0.Add(ChooseFileBtn);
        //hb0.Add(okBtn);
        //hb0.Add(cancelBtn);
        #endregion
    }
Пример #2
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>();
    }