Esempio n. 1
0
        private void CellGUI(Rect cellRect, AssetReferenceTreeItem item, int column, ref RowGUIArgs args)
        {
            Color oldColor = GUI.color;

            CenterRectUsingSingleLineHeight(ref cellRect);
            GUI.color = Color.white;

            switch (column)
            {
            case 0:
            {
                var icon = item.asset.isProjectAsset ? AssetDatabase.GetCachedIcon(item.asset.importFrom) : null;
                if (icon == null)
                {
                    icon = AssetPreview.GetMiniTypeThumbnail(item.asset.assetType);
                }
                else
                {
                    this.Repaint();
                }

                var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit);
                }
                DefaultGUI.Label(
                    new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height),
                    item.displayName,
                    args.selected,
                    args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, item.asset.variantName, args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, item.fileSize, args.selected, args.focused);
                break;
            }
            GUI.color = oldColor;
            if (Event.current.type == EventType.ContextClick && cellRect.Contains(Event.current.mousePosition))
            {
                var menu = new GenericMenu();
                menu.AddItem(new GUIContent("Copy Asset Path"), false, () =>
                {
                    EditorGUIUtility.systemCopyBuffer = item.asset.path;
                });
                if (File.Exists(item.asset.importFrom))
                {
                    menu.AddItem(new GUIContent("Open"), false, () => {
                        AssetDatabase.OpenAsset(item.asset.allData);
                    });
                }
                menu.ShowAsContext();
                Event.current.Use();
            }
        }
Esempio n. 2
0
        protected override TreeViewItem BuildRoot()
        {
            var root = new AssetReferenceTreeItem();

            foreach (var a in m_assets)
            {
                root.AddChild(new AssetReferenceTreeItem(a));
            }

            return(root);
        }
Esempio n. 3
0
        private void CellGUI(Rect cellRect, AssetReferenceTreeItem item, int column, ref RowGUIArgs args)
        {
            Color oldColor = GUI.color;

            CenterRectUsingSingleLineHeight(ref cellRect);
            GUI.color = Color.white;

            switch (column)
            {
            case 0:
            {
                var iconRect = new Rect(cellRect.x + 1, cellRect.y + 1, cellRect.height - 2, cellRect.height - 2);
                var icon     = item.icon;
                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon, ScaleMode.ScaleToFit);
                }
                DefaultGUI.Label(
                    new Rect(cellRect.x + iconRect.xMax + 1, cellRect.y, cellRect.width - iconRect.width, cellRect.height),
                    item.displayName,
                    args.selected,
                    args.focused);
            }
            break;

            case 1:
                DefaultGUI.Label(cellRect, item.asset.variantName, args.selected, args.focused);
                break;

            case 2:
                DefaultGUI.Label(cellRect, item.fileSize, args.selected, args.focused);
                break;

            case 3:
                DefaultGUI.Label(cellRect, item.runtimeMemorySize, args.selected, args.focused);
                break;
            }
            GUI.color = oldColor;
        }