Exemplo n.º 1
0
    public static LayoutConstraint GetSpliterConstraint(float offset, bool inv = false)
    {
        LayoutConstraint c = new LayoutConstraint();

        c.spliterOffset    = offset;
        c.spliterOffsetInv = inv;
        return(c);
    }
Exemplo n.º 2
0
    public static LayoutConstraint GetExtensibleViewConstraint()
    {
        LayoutConstraint c = new LayoutConstraint();

        c.expandHeight = true;
        c.expandWidth  = true;
        return(c);
    }
Exemplo n.º 3
0
    public static LayoutConstraint GetInspectorViewConstraint(float minWidth, float minHeight)
    {
        LayoutConstraint c = new LayoutConstraint();

        c.useMinWidth  = true;
        c.useMinHeight = true;
        c.minWidth     = minWidth;
        c.minHeight    = minHeight;
        return(c);
    }
Exemplo n.º 4
0
    public static LayoutConstraint GetToolBarConstraint(float h)
    {
        LayoutConstraint c = new LayoutConstraint();

        c.useMinHeight = true;
        c.minHeight    = h;

        c.useMaxHeight = true;
        c.maxHeight    = h;
        return(c);
    }
    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;
        }

        HSpliterCtrl hspliter = new HSpliterCtrl();

        hspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);

        s_root.RootCtrl = hspliter;

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

        hspliter.Add(vb0);

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

        hspliter.Add(hb0);


        TreeViewCtrl treeView = new TreeViewCtrl();

        treeView.Name          = "_MainTreeView";
        treeView.onValueChange = OnTreeViewNodeToggle;
        vb0.Add(treeView);

        Rect       btnRect = new Rect(0, 0, 60, 20);
        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(okBtn);
        hb0.Add(cancelBtn);
    }
Exemplo n.º 6
0
		internal virtual void OnConstraintChanged(LayoutConstraint oldConstraint, LayoutConstraint newConstraint)
		{
			ComputeConstrainsForChildren();
		}
Exemplo n.º 7
0
 internal virtual void OnConstraintChanged(LayoutConstraint oldConstraint, LayoutConstraint newConstraint)
 {
     ComputeConstrainsForChildren();
 }
Exemplo n.º 8
0
    //构建控件
    public static void InitControls(EditorRoot editorRoot)
    {
        s_root = editorRoot;

        editorRoot.RootCtrl = new HSpliterCtrl();
        (editorRoot.RootCtrl as SpliterCtrl).Dragable = false;
        editorRoot.RootCtrl.layoutConstraint          = LayoutConstraint.GetSpliterConstraint(30);

        HBoxCtrl menuArea = new HBoxCtrl();

        editorRoot.RootCtrl.Add(menuArea);

        _BuildMenuButtons(menuArea);

        HSpliterCtrl h1 = new HSpliterCtrl();

        h1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30);
        editorRoot.RootCtrl.Add(h1);

        HBoxCtrl playCtrlArea = new HBoxCtrl();

        h1.Add(playCtrlArea);

        //播放控件
        PlayCtrl playCtrl = new PlayCtrl();

        playCtrl.Name          = s_playCtrlName;
        playCtrl.onValueChange = OnPlayCtrlValueChange;
        playCtrl.onStop        = OnPlayCtrlStop;
        playCtrlArea.Add(playCtrl);

        VSpliterCtrl v1 = new VSpliterCtrl();

        v1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(200);
        v1.Dragable         = false;
        VBoxCtrl speListArea = new VBoxCtrl();

        v1.Add(speListArea);
        h1.Add(v1);

        //特效动画子项列表
        ListViewCtrl speListView = new ListViewCtrl();

        speListView.Name             = s_speListCtrlName;
        speListView.onAcceptDragObjs = OnSpeListAcceptDragObjs;
        speListView.onDropObjs       = OnSpeListDropObjs;
        speListView.onItemSelected   = OnSpeListItemSelect;
        speListView.onDoubleClick    = OnSpeListItemDoubleClick;
        speListView.onScroll         = OnSpeListScroll;
        //speListView.onItemSelectedR = OnSpeListItemRightBtnUp;
        speListView.onItemSelectedRU = OnSpeListItemRightBtnUp;
        speListArea.Add(speListView);

        VSpliterCtrl v2 = new VSpliterCtrl();

        v2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(400, true);
        v2.Dragable         = true;
        v1.Add(v2);

        VBoxCtrl timeLineViewArea = new VBoxCtrl();

        v2.Add(timeLineViewArea);

        //时间线控件
        TimeLineViewCtrl timeLineView = new TimeLineViewCtrl();

        timeLineView.Name           = s_speTimeLineCtrlName;
        timeLineView.onItemSelected = OnTimeLineItemSelect;
        timeLineViewArea.Add(timeLineView);

        VBoxCtrl tabViewArea = new VBoxCtrl();

        v2.Add(tabViewArea);

        TabViewCtrl tabView = new TabViewCtrl();

        tabView.Name = s_tabViewCtrlName;
        tabViewArea.Add(tabView);
        tabView.onItemSelected = OnTabViewSelect;

        _BuildPropertyTabView(tabView);

        {//注册窗体回调
            editorRoot.onEnable  = OnEditorEnable;
            editorRoot.onDisable = OnEditorDisable;
            editorRoot.onUpdate  = OnEditorUpdate;
            editorRoot.onDestroy = OnEditorDestroy;
            editorRoot.onGUI     = OnEditorGUI;
            editorRoot.onMessage = OnEditorMessage;
        }
    }
Exemplo n.º 9
0
    public override bool PreVisitChild(EditorControl c, int i)
    {
        Rect             currArea = areaStack.Peek();
        Rect             newArea = new Rect();
        LayoutConstraint constraint = c.layoutConstraint;
        float            part0Width, part0Height, part1Width, part1Height;

        //Modify by liteng for 代码改善 at 2015/2/26
        if (c is HSpliterCtrl)
        {
            if (!constraint.spliterOffsetInv)
            {
                part0Height = constraint.spliterOffset;
                part1Height = currArea.height - constraint.spliterOffset;
                if (part1Height < 0.0f)
                {
                    part1Height = 1.0f;
                }
            }
            else
            {
                part1Height = constraint.spliterOffset;
                part0Height = currArea.height - constraint.spliterOffset;
                if (part0Height < 0.0f)
                {
                    part0Height = 1.0f;
                }
            }

            if (i == 0)
            {
                newArea.Set(0, 0, currArea.width, part0Height);
            }
            else if (i == 1)
            {
                newArea.Set(0, 0, currArea.width, part1Height);
            }
            areaStack.Push(newArea);
        }
        //Modify by liteng for 代码改善 at 2015/2/26
        else if (c is VSpliterCtrl)
        {
            if (!constraint.spliterOffsetInv)
            {
                part0Width = constraint.spliterOffset;
                part1Width = currArea.width - constraint.spliterOffset;
                if (part1Width < 0.0f)
                {
                    part1Width = 1.0f;
                }
            }
            else
            {
                part1Width = constraint.spliterOffset;
                part0Width = currArea.width - constraint.spliterOffset;
                if (part0Width < 0.0f)
                {
                    part0Width = 1.0f;
                }
            }

            if (i == 0)
            {
                newArea.Set(0, 0, part0Width, currArea.height);
            }
            else if (i == 1)
            {
                newArea.Set(0, 0, part1Width, currArea.height);
            }
            areaStack.Push(newArea);
        }
        //Modify by liteng for 代码改善 at 2015/2/26
        else if (c is HBoxCtrl)
        {
        }
        //Modify by liteng for 代码改善 at 2015/2/26
        else if (c is VBoxCtrl)
        {
        }

        return(true);
    }
Exemplo n.º 10
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
    }
Exemplo n.º 11
0
    public static void InitControls(EditorRoot root)
    {
        /*将编辑器分为上下两个区域*/
        HSpliterCtrl Upanddown = new HSpliterCtrl();

        root.RootCtrl = Upanddown;
        Upanddown.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);

        #region 编辑器事件回调
        /*编辑器初始化事件*/
        root.onEnable += EditorWindowOnEnable;
        /*编辑器关闭事件*/
        root.onDestroy += EditorWindowOnDestroy;
        #endregion

        #region 编辑器的上边
        /*存放上方资源的容器*/
        HBoxCtrl upspliter = new HBoxCtrl();
        Upanddown.Add(upspliter);

        /*扫描资源按钮*/
        Rect       SearchBtnRect = new Rect(0, 0, 160, 20);
        ButtonCtrl SearchBtn     = new ButtonCtrl();
        SearchBtn.onClick  = SearchBtnClickEvent;
        SearchBtn.Size     = SearchBtnRect;
        SearchBtn.Visiable = true;
        SearchBtn.Caption  = "扫描资源";
        SearchBtn.Name     = "_SearchButton";

        /*下拉菜单,过滤器*/
        Rect ComboxFliterRect         = new Rect(0, 0, 120, 20);
        ComboBoxCtrl <int> TypeFliter = new ComboBoxCtrl <int>(0);
        TypeFliter.Size           = ComboxFliterRect;
        TypeFliter.Name           = "_TypeFliter";
        TypeFliter.onValueChange += FilterOnchange;

        for (int i = 0; i <= 3; i++)
        {
            TypeFliter.AddItem(new ComboItem("选项0", 0));
            TypeFliter.AddItem(new ComboItem("选项1", 1));
            TypeFliter.AddItem(new ComboItem("选项2", 2));
            TypeFliter.AddItem(new ComboItem("选项3", 3));
        }

        TypeFliter.CurrValue = 0;

        /*数据库状态显示*/
        LabelCtrl StateLabel = new LabelCtrl();
        StateLabel.Caption = "数据库没有更新,请点击刷新资源数据库";
        StateLabel.Name    = "_StateLabel";

        /*将控件放入上方资源*/
        upspliter.Add(SearchBtn);
        upspliter.Add(TypeFliter);
        upspliter.Add(StateLabel);
        #endregion

        #region 编辑器的下边
        /*将下放资源分为左右两个区域*/
        VSpliterCtrl downspliter = new VSpliterCtrl();
        Upanddown.Add(downspliter);
        downspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f);
        downspliter.Dragable         = true;

        /*存放左侧资源列表和无引用资源的容器*/
        VBoxCtrl LeftAssetContainer = new VBoxCtrl();
        downspliter.Add(LeftAssetContainer);

        /*左侧两枚选项卡*/
        TabViewCtrl leftTabView = new TabViewCtrl();
        LeftAssetContainer.Add(leftTabView);

        /*资源列表*/
        TreeViewCtrl AssetsTreeView = new TreeViewCtrl();
        AssetsTreeView.Caption = "资源列表";
        AssetsTreeView.Name    = "_AssetList";
        leftTabView.Add(AssetsTreeView);

        /*无用资源列表*/
        ListViewCtrl UseLessAssetsList = new ListViewCtrl();
        UseLessAssetsList.Caption = "无用资源";
        UseLessAssetsList.Name    = "_UseLessAssetsList";
        leftTabView.Add(UseLessAssetsList);

        /*存放正向反向资源依赖关系的容器*/
        VBoxCtrl RightAssetDependceContainer = new VBoxCtrl();
        downspliter.Add(RightAssetDependceContainer);

        /*右侧两枚选项卡*/
        TabViewCtrl rightTabView = new TabViewCtrl();
        RightAssetDependceContainer.Add(rightTabView);

        /*资源正向依赖关系列表*/
        ListViewCtrl DependcyAssetsList = new ListViewCtrl();
        DependcyAssetsList.Caption = "正向依赖关系";
        DependcyAssetsList.Name    = "_DependAssetsList";
        rightTabView.Add(DependcyAssetsList);

        /*资源反向依赖关系列表*/
        ListViewCtrl DedependcyAssetsList = new ListViewCtrl();
        DedependcyAssetsList.Caption = "反向依赖关系";
        DedependcyAssetsList.Name    = "_DedependcyAssetsList";
        rightTabView.Add(DedependcyAssetsList);
        #endregion
    }
Exemplo n.º 12
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>();
    }
    //这个方法就是利用EditorManager回调回来的一个EditorRoot实例;
    //构建了一个树形结构;
    public static void InitControls(EditorRoot editorRoot)
    {
        //将之前实例化的那个EditorWindow赋值给s_root
        s_root = editorRoot;

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

        {//对编辑器全局消息响应;
            EditorApplication.projectWindowItemOnGUI += OnProjectWindowItem;
            EditorApplication.projectWindowChanged   += OnProjectWindowChanged;
        }

        {//协程回调
            s_root.onCoroutineMessage      = OnCoroutineMessage;
            s_root.onCoroutineTaskFinished = OnCoroutineTaskFinished;
            s_root.onDestroy = OnDestroy;
            s_root.onEnable  = OnEnable;
        }

        {//注册数据库变化回调
            ResourceManageToolModel.GetInstance().onResourceDBUpdate      = OnAssetDatabaseUpdate;
            ResourceManageToolModel.GetInstance().onResrouceDBStateChange = OnAssetDatabaseStateChange;
        }

        HSpliterCtrl hspliter = new HSpliterCtrl();

        s_root.RootCtrl           = hspliter;
        hspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);

        //用来放置上方菜单
        HBoxCtrl     hb0      = new HBoxCtrl();
        VSpliterCtrl vspliter = new VSpliterCtrl();

        vspliter.layoutConstraint = LayoutConstraint.GetSpliterConstraint(300f);
        vspliter.Dragable         = true;

        hspliter.Add(hb0);
        hspliter.Add(vspliter);

        //用来存放 资源列表、无引用资源列表
        VBoxCtrl vb0 = new VBoxCtrl();
        //用来存放 资源依赖项、反向引用
        VBoxCtrl vb1 = new VBoxCtrl();

        vspliter.Add(vb0);
        vspliter.Add(vb1);

        //左侧TabView
        TabViewCtrl leftTabView = new TabViewCtrl();
        //右侧TabView
        TabViewCtrl rightTabView = new TabViewCtrl();

        vb0.Add(leftTabView);
        vb1.Add(rightTabView);

        //资源列表
        TreeViewCtrl resTreeList = new TreeViewCtrl();

        resTreeList.Caption        = "资源列表";
        resTreeList.Name           = "_ResTreeList";
        resTreeList.onItemSelected = OnResourcesTreeViewSelectChanged;

        //无引用资源列表
        ListViewCtrl unUsedList = new ListViewCtrl();

        unUsedList.Caption        = "无引用资源";
        unUsedList.Name           = "_UnUsedResList";
        unUsedList.onItemSelected = OnUnUsedResourcesListViewSelectChanged;

        leftTabView.Add(resTreeList);
        leftTabView.Add(unUsedList);

        //资源依赖项
        TreeViewCtrl resRefTreeView = new TreeViewCtrl();

        resRefTreeView.Caption = "资源依赖项";
        resRefTreeView.Name    = "_ResRefTreeView";


        //反向引用
        TreeViewCtrl resReverseRefTreeView = new TreeViewCtrl();

        resReverseRefTreeView.Caption = "反向引用";
        resReverseRefTreeView.Name    = "_ResReverseRefTreeView";

        rightTabView.Add(resRefTreeView);
        rightTabView.Add(resReverseRefTreeView);


        Rect       btnRect   = new Rect(0, 0, 120, 20);
        ButtonCtrl searchBtn = new ButtonCtrl();

        searchBtn.Name     = "_SearchAllResources";
        searchBtn.Caption  = "扫描资源!";
        searchBtn.Size     = btnRect;
        searchBtn.onClick += OnSearchAllAssets;
        searchBtn.BtnColor = Color.green;
        searchBtn.Visiable = true;

        Rect comboBoxRect = new Rect(0, 0, 100, 20);
        ComboBoxCtrl <int> assetTypeCombo = new ComboBoxCtrl <int>(0);

        assetTypeCombo.Size          = comboBoxRect;
        assetTypeCombo.Name          = "_AssetTypeCombo";
        assetTypeCombo.onValueChange = OnFilterComboSelectChanged;

        List <IAssetFilter> assetFilters = ResourceManageToolModel.GetInstance().AssetFilterList;

        foreach (var filter in assetFilters)
        {
            AssetTypeFilter f = filter as AssetTypeFilter;
            assetTypeCombo.AddItem(new ComboItem(f.DisplayTypeName, f.TypeIndex));
        }

        assetTypeCombo.CurrValue = 0;

        TextBoxCtrl searchTextBox = new TextBoxCtrl();

        searchTextBox.Size          = comboBoxRect;
        searchTextBox.Icon          = UnityInternalIconCache.GetInstance().GetCacheIcon("d_ViewToolZoom");
        searchTextBox.Name          = "_SearchBox";
        searchTextBox.Caption       = "搜索";
        searchTextBox.Visiable      = true;
        searchTextBox.onValueChange = OnSearchTextBoxChange;

        ButtonCtrl helpBtn = new ButtonCtrl();

        helpBtn.Name     = "_HelpButton";
        helpBtn.Caption  = "帮助文档";
        helpBtn.onClick  = OnHelp;
        helpBtn.Size     = btnRect;
        helpBtn.Visiable = true;

        LabelCtrl stateLabel = new LabelCtrl();

        stateLabel.Name             = "_StateLabel";
        stateLabel.textColor        = Color.red;
        stateLabel.Caption          = "数据库没有更新,无法查看无用资源列表与反向引用!";
        stateLabel.layoutConstraint = LayoutConstraint.GetExtensibleViewConstraint();

        hb0.Add(searchBtn);
        hb0.Add(assetTypeCombo);
        hb0.Add(searchTextBox);
        hb0.Add(helpBtn);
        hb0.Add(stateLabel);
    }
Exemplo n.º 14
0
    public static void InitControls(EditorRoot editorRoot)
    {
        SearchSpriteEditor searchSpriteEditor = editorRoot as SearchSpriteEditor;

        if (editorRoot == null)
        {
            //提示程序错误Message
            EditorUtility.DisplayDialog("运行错误",
                                        "窗口初始化失败",
                                        "确认");
            return;
        }

        m_EditorRoot = searchSpriteEditor;

        m_EditorRoot.position = new Rect(100f, 100f, m_RootWidth, 768f);


        #region 创建窗口布局元素
        Rect searchTextRect = new Rect(0, 0, 300, 20);

        #region 第一级分割
        HSpliterCtrl hs1 = new HSpliterCtrl();
        hs1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f);

        HSpliterCtrl hs2 = new HSpliterCtrl();
        hs2.MinOffset        = 100f;
        hs2.layoutConstraint = LayoutConstraint.GetSpliterConstraint(30f, true);
        hs2.Dragable         = true;

        HBoxCtrl hb1 = new HBoxCtrl();      //搜索栏 HB
        HBoxCtrl hb2 = new HBoxCtrl();      //预览区 HB
        VBoxCtrl vb3 = new VBoxCtrl();      //结果List HB
        #endregion

        #region 第二级分割
        VSpliterCtrl vs2_1 = new VSpliterCtrl();
        vs2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(m_RootWidth / 2);
        vs2_1.Dragable         = true;

        VBoxCtrl vb2_1 = new VBoxCtrl();
        VBoxCtrl vb2_2 = new VBoxCtrl();
        #endregion

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

        HSpliterCtrl hs2_2_1 = new HSpliterCtrl();
        hs2_2_1.layoutConstraint = LayoutConstraint.GetSpliterConstraint(10f, true);

        HBoxCtrl hb2_1_1 = new HBoxCtrl();
        HBoxCtrl hb2_1_2 = new HBoxCtrl();

        HBoxCtrl hb2_2_1 = new HBoxCtrl();
        HBoxCtrl hb2_2_2 = new HBoxCtrl();
        #endregion
        #endregion

        #region 布置窗口
        TextBoxCtrl searchTextBox = new TextBoxCtrl();
        searchTextBox.Size    = searchTextRect;
        searchTextBox.Icon    = UnityInternalIconCache.GetInstance().GetCacheIcon("d_ViewToolZoom");
        searchTextBox.Name    = m_SearchTextBoxName;
        searchTextBox.Caption = "搜索";

        ButtonCtrl vagueSearchBtn = new ButtonCtrl();
        vagueSearchBtn.Name    = m_VagueSearchBtnName;
        vagueSearchBtn.Caption = "模糊搜索";
        vagueSearchBtn.onClick = searchSpriteEditor.OnSearchBtn;

        ButtonCtrl searchBtn = new ButtonCtrl();
        searchBtn.Name    = m_SearchBtnName;
        searchBtn.Caption = "精确搜索";
        searchBtn.onClick = searchSpriteEditor.OnSearchBtn;

        ButtonCtrl setBtn = new ButtonCtrl();
        setBtn.Name    = m_SetBtnName;
        setBtn.Caption = "设置";
        setBtn.onClick = searchSpriteEditor.OnSetBtn;

        ButtonCtrl helpBtn = new ButtonCtrl();
        helpBtn.Name    = m_HelpBtnName;
        helpBtn.Caption = "帮助";
        helpBtn.onClick = searchSpriteEditor.OnHelpBtnClick;

        hb1.Add(searchTextBox);
        hb1.Add(vagueSearchBtn);
        hb1.Add(searchBtn);
        hb1.Add(setBtn);
        hb1.Add(helpBtn);

        MainViewCtrl spriteView = new MainViewCtrl();
        spriteView.Name     = m_SpriteViewName;
        spriteView.bkColor  = Color.gray;
        spriteView.Is2DView = true;

        LabelCtrl spriteInfoLabel = new LabelCtrl();
        spriteInfoLabel.Name    = m_SpriteInfoLabel;
        spriteInfoLabel.Caption = "";

        MainViewCtrl atlasView = new MainViewCtrl();
        atlasView.Name     = m_AtlasViewName;
        atlasView.bkColor  = Color.gray;
        atlasView.Is2DView = true;

        LabelCtrl atlasInfoLabel = new LabelCtrl();
        atlasInfoLabel.Name    = m_AtlasInfoLabel;
        atlasInfoLabel.Caption = "";

        hb2_1_1.Add(spriteView);
        hb2_1_2.Add(spriteInfoLabel);

        hb2_2_1.Add(atlasView);
        hb2_2_2.Add(atlasInfoLabel);

        hs2_1_1.Add(hb2_1_1);
        hs2_1_1.Add(hb2_1_2);

        hs2_2_1.Add(hb2_2_1);
        hs2_2_1.Add(hb2_2_2);

        vb2_1.Add(hs2_1_1);
        vb2_2.Add(hs2_2_1);

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

        hb2.Add(vs2_1);

        ListViewCtrl searchResultList = new ListViewCtrl();
        searchResultList.Name            = m_SearchResultListName;
        searchResultList.onItemSelected  = searchSpriteEditor.OnSelectListItem;
        searchResultList.onItemSelectedR = searchSpriteEditor.OnSelectListItem;

        SpaceCtrl spaceCtrl = new SpaceCtrl();
        spaceCtrl.CurrValue = 30f;

        vb3.Add(searchResultList);
        vb3.Add(spaceCtrl);

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

        hs2.Add(hb2);
        hs2.Add(vb3);

        m_EditorRoot.RootCtrl = hs1;
        #endregion

        m_EditorRoot.onGUI = searchSpriteEditor.OnEditorGUI;
    }