コード例 #1
0
        private void initTreeView()
        {
            treeViewState = new TreeViewState();

            List <AssetElement> treeEles = new List <AssetElement>();

            treeEles.Add(new AssetElement("root", -1, 0));

            treeModel = new AssetTreeModel(treeEles);
            treeModel.modelChanged += onTreeModelChanged;

            var headerState = AssetTreeView.CreateDefaultMultiColumnHeaderState(multiColumnTreeViewRect.width);

            if (MultiColumnHeaderState.CanOverwriteSerializedFields(multiColumnHeaderState, headerState))
            {
                MultiColumnHeaderState.OverwriteSerializedFields(multiColumnHeaderState, headerState);
            }
            multiColumnHeaderState = headerState;

            MultiColumnHeader multiColumnHeader = new MultiColumnHeader(headerState);

            multiColumnHeader.ResizeToFit();

            treeView      = new AssetTreeView(treeViewState, multiColumnHeader, treeModel);
            m_SearchField = new SearchField();
            m_SearchField.downOrUpArrowKeyPressed += treeView.SetFocusAndEnsureSelectedItem;
        }
コード例 #2
0
        public AssetTreeView(TreeViewState state, MultiColumnHeader multiColumnHeader, TreeModel <AssetElement> model) :
            base(state, multiColumnHeader, model)
        {
            assetTreeModel = model as AssetTreeModel;

            rowHeight = kRowHeights;
            columnIndexForTreeFoldouts    = 1;
            showAlternatingRowBackgrounds = true;
            showBorder                        = true;
            customFoldoutYOffset              = (kRowHeights - EditorGUIUtility.singleLineHeight) * 0.5f; // center foldout in the row since we also center content. See RowGUI
            extraSpaceBeforeIconAndLabel      = kToggleWidth;
            multiColumnHeader.sortingChanged += OnSortingChanged;

            Reload();
        }