Exemplo n.º 1
0
 private void DownIncr()
 {
     UpdateInput();
     Value -= Step;
     TextBoxCtrl.Focus();
     TextBoxCtrl.SelectAll();
 }
Exemplo n.º 2
0
    static void _BuildPropertyTabView(EditorControl parent)
    {
        VBoxCtrl vb0 = new VBoxCtrl();

        vb0.Caption = "属性";
        parent.Add(vb0);

        ComboBoxCtrl <int> deathTypeComboBox = new ComboBoxCtrl <int>();

        deathTypeComboBox.Name          = s_deathTypeComboBoxName;
        deathTypeComboBox.Caption       = "死亡类型";
        deathTypeComboBox.onValueChange = OnDeathTypeComboBoxValueChange;
        vb0.Add(deathTypeComboBox);

        VBoxCtrl vb1 = new VBoxCtrl();

        vb1.Caption = "骨骼绑定";
        parent.Add(vb1);

        ComboBoxCtrl <int> bindingTargetComboBox = new ComboBoxCtrl <int>();

        bindingTargetComboBox.Name          = s_bindingTargetComboBoxName;
        bindingTargetComboBox.Caption       = "绑定骨骼";
        bindingTargetComboBox.onValueChange = OnBindingTargetComboBoxValueChange;
        vb1.Add(bindingTargetComboBox);

        TextBoxCtrl bindingTargetTextBox = new TextBoxCtrl();

        bindingTargetTextBox.Name    = s_bindingTargetTextBoxName;
        bindingTargetTextBox.Caption = "绑定骨骼路径";
        bindingTargetTextBox.Enable  = false;
        vb1.Add(bindingTargetTextBox);
    }
 private void OnOperateAction(OperateAction OpAct)
 {
     UpdateInput();
     OpAct();
     TextBoxCtrl.Focus();
     TextBoxCtrl.SelectAll();
 }
Exemplo n.º 4
0
    static void _BuildMenuButtons(EditorControl parent)
    {
        Rect btnRect = new Rect(0, 0, 60, 20);
        //Rect undoRect = new Rect(0, 0, 120, 20);
        //Rect colorCtrlRect = new Rect(0, 0, 200, 20);
        //Rect returnBtnRect = new Rect(0, 0, 120, 20);

        ButtonCtrl newBtn = new ButtonCtrl();

        newBtn.Name    = s_newBtnName;
        newBtn.Caption = "新建";
        newBtn.Size    = btnRect;
        newBtn.onClick = OnNewBtnClick;
        parent.Add(newBtn);

        ButtonCtrl saveBtn = new ButtonCtrl();

        saveBtn.Name    = s_saveBtnName;
        saveBtn.Caption = "保存";
        saveBtn.Size    = btnRect;
        saveBtn.onClick = OnSaveBtnClick;
        parent.Add(saveBtn);


        ButtonCtrl undoBtn = new ButtonCtrl();

        undoBtn.Name    = s_undoBtnName;
        undoBtn.Caption = "撤消";
        undoBtn.Size    = btnRect;
        undoBtn.onClick = OnUndoBtnClick;
        parent.Add(undoBtn);

        ButtonCtrl redoBtn = new ButtonCtrl();

        redoBtn.Name    = s_redoBtnName;
        redoBtn.Caption = "重做";
        redoBtn.Size    = btnRect;
        redoBtn.onClick = OnRedoBtnClick;
        parent.Add(redoBtn);

        TextBoxCtrl openFileTextBox = new TextBoxCtrl();

        openFileTextBox.Name    = s_openFileTextBoxName;
        openFileTextBox.Caption = "当前打开文件";
        openFileTextBox.Enable  = false;
        openFileTextBox.Text    = "空";
        openFileTextBox.Size    = new Rect(0, 0, 150, 20);
        parent.Add(openFileTextBox);

        ObjectFieldCtrl previewModelCtrl = new ObjectFieldCtrl();

        previewModelCtrl.Name               = s_previewModelCtrlName;
        previewModelCtrl.Caption            = "预览模型";
        previewModelCtrl.ObjectType         = typeof(GameObject);
        previewModelCtrl.IsAlowSceneObjects = false;
        previewModelCtrl.onValueChange      = OnPreviewModelValueChanged;
        parent.Add(previewModelCtrl);
    }
Exemplo n.º 5
0
    void OnSearchBtn(EditorControl c)
    {
        TextBoxCtrl searchText = _GetControl <TextBoxCtrl>(m_SearchTextBoxName);

        if (null == searchText)
        {
            return;
        }

        string spriteName = searchText.Text;
        List <AtlasInfoForSearchSprite> atlasInfoTbl = null;

        SEARCHSPRITE_ERROR_TYPE errorType = SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR;

        if (c.Name == m_VagueSearchBtnName)
        {
            errorType = SearchSpriteEidtorModel.GetInstance().VagueSearchSprite(spriteName, out atlasInfoTbl);
        }
        else
        {
            errorType = SearchSpriteEidtorModel.GetInstance().SearchSprite(spriteName, out atlasInfoTbl);
        }

        switch (errorType)
        {
        //搜索成功
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_NONE_ERROR:
            FixSearchResultAndList(spriteName, atlasInfoTbl);
            ClearPreview();

            if (
                (null == m_SearchResultInfo) ||
                (null == m_SearchResultInfo.SearchSpriteInfo) ||
                (0 == m_SearchResultInfo.SearchSpriteInfo.Count)
                )
            {    //搜索结果为空
                EditorUtility.DisplayDialog("查找完毕", "\n" + spriteName + "不存在", "确认");
            }
            else
            {    //不为空
                EditorUtility.DisplayDialog("查找完毕", "\n有" + m_SearchResultInfo.SearchSpriteInfo.Count + "个Atlas包含" + spriteName, "确认");
            }

            break;

        //未指定Sprite名称
        case SEARCHSPRITE_ERROR_TYPE.SEARCHSPRITE_SEARCH_WITH_EMPTY_NAME:
            EditorUtility.DisplayDialog("操作失败", "\n未指定Sprite名称", "确认");
            if (m_SearchResultInfo != null)
            {
                searchText.Text = m_SearchResultInfo.SearchName;
            }
            break;

        default:
            break;
        }
    }
Exemplo n.º 6
0
    public override void Visit(EditorControl c)
    {
        TextBoxCtrl textBox = c as TextBoxCtrl;

        currCtrl = c as TextBoxCtrl;
        if (
            (null == textBox)
            )
        {
            return;
        }

        EditorGUI.BeginDisabledGroup(!textBox.Enable);

        textBoxContent.text = textBox.Caption;
        if (textBox.Icon != null)
        {
            textBoxContent.image = textBox.Icon;
        }

        lastText = textBox.Text;

        EditorGUILayout.BeginHorizontal();
        Vector2 labelSize = EditorStyles.label.CalcSize(textBoxContent);

        EditorGUILayout.LabelField(textBoxContent, new GUILayoutOption[] { GUILayout.Width(labelSize.x) });

        GUI.SetNextControlName(textBox.CtrlID);
        textBox.Text          = EditorGUILayout.TextField(textBox.Text, textBox.GetOptions());
        textBox.IsForceUpdate = false;

        EditorGUILayout.EndHorizontal();

        if (
            (lastText != null) &&
            !lastText.Equals(textBox.Text)
            )
        {
            textBox.frameTriggerInfo.isValueChanged = true;
            lastText = textBox.Text;

            textBox.RequestRepaint();
        }

        EditorGUI.EndDisabledGroup();

        c.UpdateLastRect();

        HandleDragAction(c);

        CheckInputEvent(c);
    }
    /*
     * 搜索框
     */

    //Modify by lteng for 追加共通控件 At 2015/2/26
    static void OnSearchTextBoxChange(EditorControl c, object value)
    {
        TextBoxCtrl        searchBox          = s_root.FindControl("_SearchBox") as TextBoxCtrl;
        ComboBoxCtrl <int> typeFilterComboBox = s_root.FindControl("_AssetTypeCombo") as ComboBoxCtrl <int>;

        typeFilterComboBox.CurrValue = 0;
        if (searchBox.Text.Length == 0)
        {
            ResourceManageToolModel.GetInstance().SetFilter(0);
        }
        else
        {
            AssetNameFilter nameFilter = new AssetNameFilter();
            nameFilter.SearchText = searchBox.Text;
            ResourceManageToolModel.GetInstance().SetFilter(nameFilter);
        }
        RequestRepaint();
    }
        private void TextBoxCtrl_PreviewDragOver(object sender, DragEventArgs e)
        {
            Control ctrl = sender as Control;

            if (ctrl != null)
            {
                string DragTxt = (string)e.Data.GetData("Text");
                Point  pt      = e.GetPosition(TextBoxCtrl);
                Object obj     = e.Source;

                TextBoxCtrl.Focus();

                int CharPosClosest = TextBoxCtrl.GetCharacterIndexFromPoint(pt, true); // With SnapToText = false, always get 1 returned

                if (CharPosClosest == TextBoxCtrl.Text.Length - 1)
                {
                    // According to MSDN documentation, GetRectFromCharacterIndex always returns the zero-width rectangle preceeding
                    // the character.
                    // Documentation says nothing about one past the last character. This I just guessed. Logically it should work,
                    // and you should be able to get this information, but documentation says nothing about this.
                    Rect rc = TextBoxCtrl.GetRectFromCharacterIndex(CharPosClosest + 1);

                    if (rc.Right < pt.X)
                    {
                        CharPosClosest++;
                    }
                }
                TextBoxCtrl.SelectionStart = CharPosClosest;

                TextBoxCtrl.SelectionLength = 0;
                decimal CurrentValue;

                int    CurPos = TextBoxCtrl.SelectionStart;
                string Txt    = TextBoxCtrl.Text.Insert(CurPos, DragTxt);
                e.Effects = ValidateInput(ref Txt, out CurrentValue) ? DragDropEffects.Move : DragDropEffects.None;
            }
            e.Handled = true;
        }
    //这个方法就是利用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.º 10
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;
    }