コード例 #1
0
    //绘制Toolbar
    public void DrawOptionBar()
    {
        EditorGUILayout.BeginHorizontal(toolbarGUIStyle);

        //刷新数据
        if (GUILayout.Button("Refresh Data", toolbtnGUIStyle, GUILayout.Width(120)))
        {
            data.CollectDependenciesInfo();
            needUpdateAssetTree = true;
            EditorGUIUtility.ExitGUI();
        }

        //修改模式
        bool preIsDependency = isDependency;

        isDependency = GUILayout.Toggle(isDependency, isDependency ? "Model(Dependency)" : "Model(Reference)", toolbtnGUIStyle, GUILayout.Width(150));
        if (preIsDependency != isDependency)
        {
            needUpdateAssetTree = true;
            PlayerPrefs.SetInt(IsDependencyKey, isDependency ? 1 : 0);
        }

        //是否需要更新状态
        bool preNeedUpdateState = needUpdateState;

        needUpdateState = GUILayout.Toggle(needUpdateState, "Need Update State", toolbtnGUIStyle, GUILayout.Width(150));
        if (preNeedUpdateState != needUpdateState)
        {
            PlayerPrefs.SetInt(NeedUpdateStateKey, needUpdateState ? 1 : 0);
        }

        GUILayout.FlexibleSpace();

        //扩展
        if (GUILayout.Button("Expand", toolbtnGUIStyle))
        {
            if (m_AssetTreeView != null)
            {
                m_AssetTreeView.ExpandAll();
            }
        }
        //折叠
        if (GUILayout.Button("Collapse", toolbtnGUIStyle))
        {
            if (m_AssetTreeView != null)
            {
                m_AssetTreeView.CollapseAll();
            }
        }
        EditorGUILayout.EndHorizontal();
    }
コード例 #2
0
 //通过选中资源列表更新TreeView
 private void UpdateAssetTree()
 {
     if (_needUpdateAssetTree && _selectedAssetGuid.Count != 0)
     {
         var root = SelectedAssetGuidToRootItem(_selectedAssetGuid);
         if (_assetTreeView == null)
         {
             //初始化TreeView
             if (_treeViewState == null)
             {
                 _treeViewState = new TreeViewState();
             }
             var headerState       = AssetTreeView.CreateDefaultMultiColumnHeaderState(position.width);
             var multiColumnHeader = new MultiColumnHeader(headerState);
             _assetTreeView = new AssetTreeView(_treeViewState, multiColumnHeader);
         }
         _assetTreeView.assetRoot = root;
         _assetTreeView.CollapseAll();
         _assetTreeView.Reload();
         _assetTreeView.ExpandAll();
         _needUpdateAssetTree = false;
     }
 }