コード例 #1
0
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);

            if (render != null)
            {
                AssetDragAndDropArgs copyArgs = new AssetDragAndDropArgs();
                copyArgs.dragAndDropPosition = (AssetDragAndDropArgs.DragAndDropPosition)((int)args.dragAndDropPosition);
                copyArgs.insertAtIndex       = args.insertAtIndex;
                copyArgs.parentItem          = args.parentItem;
                copyArgs.performDrop         = args.performDrop;
                DragAndDropVisualMode result = DragAndDropVisualMode.Move;
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == _viewMode)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Drag(ref copyArgs, ref result);
                        }
                    }
                }
                return(result);
            }

            return(base.HandleDragAndDrop(args));
        }
コード例 #2
0
        void OnSortingChanged(MultiColumnHeader header)
        {
            if (GetRows().Count <= 1 || header.sortedColumnIndex < 0 || !header.canSort)
            {
                return;
            }

            var md     = EditorContexts.mIns.Mode;
            var render = AssetTreeManager.mIns.GetGuiRender(md);

            if (render != null)
            {
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == _viewMode)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Sort(header, rootItem, GetRows());
                        }
                    }
                }
            }

            AssetBundleEditorHelper.TreeListChildren(rootItem, GetRows());
            Repaint();
        }
コード例 #3
0
        public void RefreshGuiInfo(AssetWindow window)
        {
            var guirender = AssetTreeManager.mIns.GetGuiRender(Mode);

            if (GuiContext.WindowRect.width > 0 && GuiContext.WindowRect.height > 0 && (Mathf.Abs(GuiContext.WindowRect.width - window.position.width) > 0.1f || Mathf.Abs(GuiContext.WindowRect.height - window.position.height) > 0.1f))
            {
                if (guirender != null)
                {
                    foreach (var grender in guirender)
                    {
                        IGuiTree treeRender = grender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.RefreshHead();
                        }
                    }
                }
            }

            GuiContext.WindowRect  = new Rect((int)window.position.x, (int)window.position.y, (int)window.position.width, (int)window.position.height);
            GuiContext.TitleRect   = new Rect(5, 0, GuiContext.WindowRect.width - 10, EditorGuiContext.GuiHeight);
            GuiContext.ToolbarRect = new Rect(5, GuiContext.WindowRect.height - EditorGuiContext.GuiHeight, GuiContext.WindowRect.width - 10, EditorGuiContext.GuiHeight);

            if (guirender != null)
            {
                foreach (var grender in guirender)
                {
                    grender.RefreshGuiInfo(this);
                }
            }
        }
コード例 #4
0
        protected override void RowGUI(RowGUIArgs args)
        {
            try
            {
                var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);
                if (render != null)
                {
                    var item = (AssetTreeItem <T>)args.item;
                    for (int i = 0; i < args.GetNumVisibleColumns(); ++i)
                    {
                        AssetRowGuiArgs copyArgs = new AssetRowGuiArgs();
                        copyArgs.item       = args.item;
                        copyArgs.focused    = args.focused;
                        copyArgs.isRenaming = args.isRenaming;
                        copyArgs.label      = args.label;
                        copyArgs.row        = args.row;
                        copyArgs.rowRect    = args.rowRect;
                        copyArgs.selected   = args.selected;

                        //
                        copyArgs.CellRect = args.GetCellRect(i);
                        copyArgs.Column   = args.GetColumn(i);

                        foreach (var subrender in render)
                        {
                            if (subrender.TypeMode == _viewMode)
                            {
                                IGuiTree treeRender = subrender as IGuiTree;
                                if (treeRender != null)
                                {
                                    if (!treeRender.CellGui(item, ref copyArgs))
                                    {
                                        base.RowGUI(args);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.LogError(ex);
            }
        }
コード例 #5
0
        protected override IList <TreeViewItem> BuildRows(TreeViewItem rootitem)
        {
            var selections = GetSelection();

            _rows.Clear();

            AssetTreeItem <T> root = rootitem as AssetTreeItem <T>;

            if (root != null)
            {
                if (!string.IsNullOrEmpty(searchString))
                {
                    SearchItem(_rows, _model, root.DataId);
                }
                else
                {
                    TryAddChildren(root, _rows, _model, -1);
                }

                SetupParentsAndChildrenFromDepths(rootitem, _rows);

                var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);
                if (render != null)
                {
                    foreach (var subrender in render)
                    {
                        if (subrender.TypeMode == _viewMode)
                        {
                            IGuiTree treeRender = subrender as IGuiTree;
                            if (treeRender != null)
                            {
                                treeRender.Rebuild();
                            }
                        }
                    }
                }
            }

            if (selections != null && selections.Count > 0)
            {
                FrameItem(selections[0]);
            }

            return(_rows);
        }
コード例 #6
0
        protected override bool CanStartDrag(CanStartDragArgs args)
        {
            var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);

            if (render != null)
            {
                bool ret = false;
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == _viewMode)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.CanDrag(ref ret);
                        }
                    }
                }
                return(ret);
            }
            return(false);
        }
コード例 #7
0
        IEnumerator InitForWindow()
        {
            EditorContexts.mIns.GuiContext.IsLoading = true;
            if (!Inited)
            {
                var logic = AssetTreeManager.mIns.Get(EditorContexts.mIns.Mode);
                if (logic != null)
                {
                    for (int i = 0; i < logic.Count; i++)
                    {
                        logic[i].Clear();
                        yield return(logic[i].ReLoad());
                    }
                }

                EditorContexts.mIns.RefreshGuiInfo(this);

                var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);
                if (render != null)
                {
                    foreach (var subrender in render)
                    {
                        subrender.Init();
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Refresh();
                        }
                    }
                }

                Inited = true;
                EditorUtility.ClearProgressBar();

                Repaint();
            }
            EditorContexts.mIns.GuiContext.IsLoading = false;
        }
コード例 #8
0
        IEnumerator DoForceModeChange(AssetWindow.WindowMode md)
        {
            GuiContext.IsLoading = true;
            var logic = AssetTreeManager.mIns.Get(md);

            if (logic != null)
            {
                foreach (var sublogic in logic)
                {
                    if (sublogic.TypeMode == md)
                    {
                        sublogic.Clear();
                        yield return(sublogic.ReLoad());
                    }
                }
            }

            var render = AssetTreeManager.mIns.GetGuiRender(md);

            if (render != null)
            {
                foreach (var subrender in render)
                {
                    if (subrender.TypeMode == md)
                    {
                        IGuiTree treeRender = subrender as IGuiTree;
                        if (treeRender != null)
                        {
                            treeRender.Refresh();
                        }
                    }
                }
            }

            EditorUtility.ClearProgressBar();
            GuiContext.IsLoading = false;
        }
コード例 #9
0
        protected override void SelectionChanged(IList <int> selectedIds)
        {
            if (selectedIds.Count > 0)
            {
                FrameItem(selectedIds[0]);

                var render = AssetTreeManager.mIns.GetGuiRender(EditorContexts.mIns.Mode);
                if (render != null)
                {
                    List <TreeViewItem> itemList = ListPool <TreeViewItem> .Get();

                    var rows = GetRows();
                    for (int i = 0; i < rows.Count; i++)
                    {
                        var rowdata = rows[i] as AssetTreeItem <T>;
                        if (rowdata != null && selectedIds.Contains(rowdata.id))
                        {
                            itemList.Add(rowdata);
                        }
                    }

                    foreach (var subrender in render)
                    {
                        if (subrender.TypeMode == _viewMode)
                        {
                            IGuiTree treeRender = subrender as IGuiTree;
                            if (treeRender != null)
                            {
                                treeRender.SelectionChanged(itemList);
                            }
                        }
                    }

                    //is searching
                    if (!string.IsNullOrEmpty(searchString))
                    {
                        IList <int> expandlist = GetExpanded();
                        if (expandlist != null)
                        {
                            List <int> list = new List <int>();
                            list.AddRange(expandlist);

                            Stack <int> stack = StackPool <int> .Get();

                            foreach (var item in itemList)
                            {
                                stack.Push(item.id);
                            }

                            while (stack.Count > 0)
                            {
                                var itemid = stack.Pop();
                                if (!list.Contains(itemid))
                                {
                                    list.Add(itemid);
                                    if (_model.HasParent(itemid))
                                    {
                                        var parents = _model.GetParent(itemid);
                                        foreach (var parent in parents)
                                        {
                                            if (!list.Contains(parent.Id) && parent.Id != _model.Root.Id)
                                            {
                                                stack.Push(parent.Id);
                                            }
                                        }

                                        ListPool <T> .Release(parents);
                                    }
                                }
                            }
                            StackPool <int> .Release(stack);

                            SetExpanded(list);
                        }
                    }

                    ListPool <TreeViewItem> .Release(itemList);
                }
                else
                {
                    base.SelectionChanged(selectedIds);
                }
            }
        }
コード例 #10
0
        IEnumerator DoModeChange(AssetWindow.WindowMode old, AssetWindow.WindowMode newmd)
        {
            GuiContext.IsLoading = true;
            bool needupdate = false;
            int  oldval     = (int)old;
            int  newval     = (int)newmd;
            int  oldmain    = oldval / 8;
            int  newmain    = newval / 8;

            if (oldmain != newmain)
            {
                var oldrender = AssetTreeManager.mIns.GetGuiRender(old);
                if (oldrender != null)
                {
                    foreach (var subrender in oldrender)
                    {
                        subrender.Destory();
                    }
                }

                needupdate = true;
            }
            else
            {
                if (newmain != newval)
                {
                    needupdate = true;
                }
            }

            if (needupdate)
            {
                //logic
                var logic = AssetTreeManager.mIns.Get(newmd);
                if (logic != null)
                {
                    foreach (var sublogic in logic)
                    {
                        if (sublogic.TypeMode == newmd)
                        {
                            sublogic.Clear();
                            yield return(sublogic.ReLoad());
                        }
                    }
                }

                var render = AssetTreeManager.mIns.GetGuiRender(newmd);
                if (render != null)
                {
                    foreach (var subrender in render)
                    {
                        if (subrender.TypeMode == newmd)
                        {
                            subrender.Init();
                            IGuiTree treeRender = subrender as IGuiTree;
                            if (treeRender != null)
                            {
                                treeRender.Refresh();
                            }
                        }
                    }
                }
            }

            EditorUtility.ClearProgressBar();
            GuiContext.IsLoading = false;
        }