Esempio n. 1
0
 public static void MarkAssetCorrupted(ref U3DAssetInfo assetInfo)
 {
     assetInfo.Corrupted = true;
     assetInfo.TypeName  = "Corrupted";
     assetInfo.icon      = UnityInternalIconCache.GetInstance().GetCacheIcon("d_console.erroricon.sml");
 }
    //这个方法就是利用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);
    }
Esempio n. 3
0
    static void RebuildListViewAndTimeLineView()
    {
        var clip = SpecialEffectAnimClipEditorModel.GetInstance().CurrentClip;

        //更新ListView
        ListViewCtrl listView = GetListViewCtrl();

        listView.ClearItems();

        var previewAnimClip = clip.PreviewAnimClip;

        {
            ListCtrlItem item = new ListCtrlItem();
            if (previewAnimClip != null)
            {
                item.name = previewAnimClip.name;
            }
            else
            {
                item.name = "空动作";
            }
            item.image = UnityInternalIconCache.GetInstance().GetCacheIcon("UnityEditor.AnimationWindow");
            listView.AddItem(item);
        }


        foreach (var item in clip.Clip.itemList)
        {
            ListCtrlItem listItem = new ListCtrlItem();
            listItem.name = item.obj.name;
            if (item as SpecialEffectAnimClipAudioItem != null)
            {
                listItem.image = UnityInternalIconCache.GetInstance().GetCacheIcon("SceneViewAudio");
            }
            else if (item as SpecialEffectAnimClipEffectItem != null)
            {
                listItem.image = UnityInternalIconCache.GetInstance().GetCacheIcon("AvatarPivot");
            }
            listView.AddItem(listItem);
        }


        //更新TimeLineView
        TimeLineViewCtrl timeLineView = GetTimeLineViewCtrl();

        timeLineView.Items.Clear();

        {
            TimeLineItem item = new TimeLineItem();
            item.startTime = 0.0f;
            if (previewAnimClip != null)
            {
                item.length = previewAnimClip.length;
            }
            else
            {
                item.length = 0.0f;
            }
            timeLineView.Items.Add(item);
        }

        foreach (var item in clip.Clip.itemList)
        {
            TimeLineItem timeLineItem = new TimeLineItem();
            timeLineItem.startTime = item.StartTime;
            timeLineItem.length    = item.Length;
            timeLineView.Items.Add(timeLineItem);
        }

        UpdatePreviewLength();
    }
Esempio n. 4
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;
    }