예제 #1
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);
            }
        }
예제 #2
0
        public bool CellGui(TreeViewItem item, ref AssetRowGuiArgs args)
        {
            if (item is AssetTreeItem <SpriteTrackData> )
            {
                AssetTreeItem <SpriteTrackData> trackItem = item as AssetTreeItem <SpriteTrackData>;

                GUI.skin.label.richText = true;
                SpriteTopMenu   topMenu = (SpriteTopMenu)args.Column;
                SpriteTrackData data    = trackItem.GetData();
                if (topMenu == SpriteTopMenu.Name)
                {
                    return(false);
                }
                else if (topMenu == SpriteTopMenu.Type)
                {
                    if (data.ShowMode == SpriteShowMode.Scene)
                    {
                        GUI.Label(args.CellRect, "Scene");
                    }
                    else if (data.ShowMode == SpriteShowMode.Prefabs)
                    {
                        GUI.Label(args.CellRect, "GameObject");
                    }
                    else if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        GUI.Label(args.CellRect, "Atlas");
                    }
                }
                else if (topMenu == SpriteTopMenu.BundleName)
                {
                    if (data.ShowMode == SpriteShowMode.Scene)
                    {
                        GUI.Label(args.CellRect, data.SceneData.SprData.BundleName);
                    }
                    else if (data.ShowMode == SpriteShowMode.Prefabs)
                    {
                        GUI.Label(args.CellRect, data.GameObjectData.SprData.BundleName);
                    }
                    else if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        GUI.Label(args.CellRect, data.AtlasData.SprData.BundleName);
                    }
                }
                else if (topMenu == SpriteTopMenu.AtlasName)
                {
                    if (data.ShowMode == SpriteShowMode.Scene)
                    {
                        if (item.depth == 2)
                        {
                            if (string.IsNullOrEmpty(data.SceneData.SprData.PackingTag) == false)
                            {
                                string newval = GUI.TextField(args.CellRect, data.SceneData.SprData.PackingTag);
                                if (CheckTag(newval, data.SceneData.SprData.PackingTag))
                                {
                                    data.SceneData.SprData.Importer.spritePackingTag = newval;
                                    data.SceneData.SprData.PackingTag = newval;
                                    data.SceneData.SprData.Importer.SaveAndReimport();

                                    trackItem.SetData(data);
                                }
                            }
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Prefabs)
                    {
                        if (item.depth == 3)
                        {
                            if (string.IsNullOrEmpty(data.GameObjectData.SprData.PackingTag) == false)
                            {
                                string newval = GUI.TextField(args.CellRect, data.GameObjectData.SprData.PackingTag);
                                if (CheckTag(newval, data.GameObjectData.SprData.PackingTag))
                                {
                                    data.GameObjectData.SprData.Importer.spritePackingTag = newval;
                                    data.GameObjectData.SprData.PackingTag = newval;
                                    data.GameObjectData.SprData.Importer.SaveAndReimport();

                                    trackItem.SetData(data);
                                }
                            }
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        if (item.depth == 2)
                        {
                            if (string.IsNullOrEmpty(data.AtlasData.SprData.PackingTag) == false)
                            {
                                string newval = GUI.TextField(args.CellRect, data.AtlasData.SprData.PackingTag);
                                if (CheckTag(newval, data.AtlasData.SprData.PackingTag))
                                {
                                    data.AtlasData.SprData.Importer.spritePackingTag = newval;
                                    data.AtlasData.SprData.PackingTag = newval;
                                    data.AtlasData.SprData.Importer.SaveAndReimport();

                                    trackItem.SetData(data);
                                }
                            }
                        }
                    }
                }
                else if (topMenu == SpriteTopMenu.UsedCount)
                {
                    if (item.depth > 0 && (data.ShowMode == SpriteShowMode.Scene || data.ShowMode == SpriteShowMode.Prefabs))
                    {
                        GUI.Label(args.CellRect, data.UsedRefCount.ToString());
                    }
                }
                else if (topMenu == SpriteTopMenu.MemSize)
                {
                    if (data.ShowMode == SpriteShowMode.Scene)
                    {
                        if (item.depth == 2)
                        {
                            GUI.Label(args.CellRect, "Spr:" + data.SceneData.SprData.MemSize + " Tex:" + data.SceneData.SprData.TexMemSize);
                        }
                        else if (item.depth > 0)
                        {
                            GUI.Label(args.CellRect, "Script:" + data.SceneData.MemSize);
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Prefabs)
                    {
                        if (item.depth == 3)
                        {
                            GUI.Label(args.CellRect, "Spr:" + data.GameObjectData.SprData.MemSize + " Tex:" + data.GameObjectData.SprData.TexMemSize);
                        }
                        else if (item.depth > 0)
                        {
                            GUI.Label(args.CellRect, "Go:" + data.GameObjectData.GoData.MemSize);
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        if (item.depth == 2)
                        {
                            GUI.Label(args.CellRect, "Spr:" + data.AtlasData.SprData.MemSize + " Tex:" + data.AtlasData.SprData.TexMemSize);
                        }
                        else if (item.depth > 1)
                        {
                            GUI.Label(args.CellRect, "Ref:" + data.AtlasData.RefData.MemSize);
                        }
                    }
                }
                else if (topMenu == SpriteTopMenu.Size)
                {
                    if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        if (data.AtlasData.SprData.Sprite != null)
                        {
                            GUI.Label(args.CellRect, data.AtlasData.SprData.TexSize.ToString());
                        }
                    }
                }
                else if (topMenu == SpriteTopMenu.Info)
                {
                    if (data.ShowMode == SpriteShowMode.Scene)
                    {
                        if (item.depth == 1)
                        {
                            if (data.SceneData.CsReferences)
                            {
                                GUI.Label(args.CellRect, string.Format("Type :{0} Path:{1} ",
                                                                       AssetBundleEditorHelper.GetColorText("{0}", Color.black, data.SceneData.CsReferences),
                                                                       AssetBundleEditorHelper.GetColorText("{0}", Color.white, data.SceneData.Path)
                                                                       ));
                            }
                        }
                        else if (item.depth == 2)
                        {
                            if (data.SceneData.SprData.Sprite)
                            {
                                GUI.Label(args.CellRect, GetSprInfo(ref data.SceneData.SprData));
                            }
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Prefabs)
                    {
                        if (item.depth == 1)
                        {
                            GUI.Label(args.CellRect, string.Format("AssetPath :{0} Path:{1} PrefabType:{2}",
                                                                   AssetBundleEditorHelper.GetColorText("{0}", Color.black, data.GameObjectData.GoData.AssetPath),
                                                                   AssetBundleEditorHelper.GetColorText("{0}", Color.white, data.GameObjectData.GoData.Path),
                                                                   AssetBundleEditorHelper.GetColorText("{0}", Color.yellow, data.GameObjectData.GoData.PrefabType)));
                        }
                        else if (item.depth == 2)
                        {
                            GUI.Label(args.CellRect, GetSprInfo(ref data.GameObjectData.SprData));
                        }
                        else if (item.depth == 3)
                        {
                            if (data.GameObjectData.SprData.Sprite)
                            {
                                GUI.Label(args.CellRect, GetSprInfo(ref data.GameObjectData.SprData));
                            }
                        }
                    }
                    else if (data.ShowMode == SpriteShowMode.Atlas)
                    {
                        if (item.depth == 2)
                        {
                            if (data.AtlasData.SprData.Sprite)
                            {
                                GUI.Label(args.CellRect, GetSprInfo(ref data.AtlasData.SprData));
                            }
                        }
                        else if (item.depth == 3)
                        {
                            if (data.AtlasData.RefData.Target)
                            {
                                GUI.Label(args.CellRect, string.Format("{0} Path:{1}",
                                                                       AssetBundleEditorHelper.GetColorText("{0}", Color.black, data.AtlasData.RefData.Target),
                                                                       AssetBundleEditorHelper.GetColorText("{0}", Color.white, data.AtlasData.RefData.Path)));
                            }
                        }
                    }
                }
                GUI.skin.label.richText = false;
            }
            else
            {
                return(false);
            }

            return(true);
        }
예제 #3
0
        public bool CellGui(TreeViewItem item, ref AssetRowGuiArgs args)
        {
            var assetitem = item as AssetTreeItem <DependencyTreeData>;

            if (assetitem != null)
            {
                var  data        = assetitem.GetData();
                var  runtimeInfo = data.EditorInfo.RuntimeInfo;
                bool isroot      = item.depth == 0;
                var  topmenutype = (TopMenu)args.Column;

                if (topmenutype == TopMenu.Name)
                {
                    return(false);
                }
                else if (topmenutype == TopMenu.ResType)
                {
                    GUI.Label(args.CellRect, GetResTypeContent(runtimeInfo.AssetResType));
                }
                else if (topmenutype == TopMenu.Size)//size
                {
                    long size = AssetBundleEditorHelper.GetAssetSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.FileSize)//file size
                {
                    long size = AssetBundleEditorHelper.GetFileSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.SelfSize)//size
                {
                    long size = AssetBundleEditorHelper.GetSelfAssetSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.SelfFileSize)//file size
                {
                    long size = AssetBundleEditorHelper.GetSelfFileSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.BeDependOn)
                {
                    if (isroot)
                    {
                        var list = _model.GetDependParents(runtimeInfo.UnityPath);

                        GUI.skin.label.richText = true;
                        var info = AssetBundleEditorHelper.GetColorText("be depond on count :{0}", Color.grey, list.Count.ToString());
                        if (!string.IsNullOrEmpty(data.EditorInfo.RuntimeInfo.AssetBundleName))
                        {
                            info += AssetBundleEditorHelper.GetColorText(" AssetBundle Name :{0},It should be Load {0} first", Color.yellow, data.EditorInfo.RuntimeInfo.AssetBundleName);
                        }
                        else
                        {
                            info += AssetBundleEditorHelper.GetColorText(" it's an noassetbundlename resource,it will pack into this assetbundle alonely", Color.white);
                        }

                        GUI.Label(args.CellRect, new GUIContent(info));
                        GUI.skin.label.richText = false;
                    }
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        //List<AssetTreeItem<AssetTreeData>g> GetSelectItems()
        //{

        //    var selects = _treeView.GetSelection();
        //    List<AssetTreeItem<AssetTreeData>> list = ListPool<AssetTreeItem<AssetTreeData>>.Get();
        //    foreach (var id in selects)
        //    {
        //        for (int i = 0; i < _treeView.GetRows().Count; i++)
        //        {
        //            var item = _treeView.GetRows()[i];
        //            if (item.id == id)
        //            {
        //                list.Add(item as AssetTreeItem<AssetTreeData>);
        //                break;
        //            }
        //        }
        //    }
        //    return list;
        //}

        public bool CellGui(TreeViewItem item, ref AssetRowGuiArgs args)
        {
            var assetitem = item as AssetTreeItem <AssetTreeData>;

            if (assetitem != null)
            {
                var  data        = assetitem.GetData();
                var  runtimeInfo = data.EditorInfo.RuntimeInfo;
                bool isroot      = item.depth == 0;
                var  topmenutype = (TopMenu)args.Column;
                if (topmenutype == TopMenu.AssetBundle)
                {
                    //GUI.Label(args.CellRect, new GUIContent(item.displayName, item.icon));
                    return(false);
                }
                else if (topmenutype == TopMenu.InAssetBundle)
                {
                    if (!isroot)
                    {
                        bool isIn  = !string.IsNullOrEmpty(runtimeInfo.AssetBundleName) && item.depth <= 1;
                        bool value = GUI.Toggle(args.CellRect, isIn, "");
                        if (isIn != value)
                        {
                            if (value)
                            {
                                if (item.parent != null && item.parent.parent != null)
                                {
                                    AssetImporter importer = AssetImporter.GetAtPath(runtimeInfo.UnityPath);
                                    if (importer != null)
                                    {
                                        importer.assetBundleName = item.parent.parent.displayName;
                                        importer.SaveAndReimport();
                                    }

                                    EditorContexts.mIns.ForceModeChange(EditorContexts.mIns.Mode);
                                }
                                else
                                {
                                    Debug.LogErrorFormat("{0} parent is Null", runtimeInfo.UnityPath);
                                }
                            }
                            else
                            {
                                AssetImporter importer = AssetImporter.GetAtPath(runtimeInfo.UnityPath);
                                if (importer != null)
                                {
                                    importer.assetBundleName = "";
                                    importer.SaveAndReimport();
                                }

                                EditorContexts.mIns.ForceModeChange(EditorContexts.mIns.Mode);
                            }
                        }
                    }
                }
                else if (topmenutype == TopMenu.ResType) //
                {
                    if (!isroot)
                    {
                        var restype = data.EditorInfo.RuntimeInfo.AssetResType;
                        EditorGUI.EnumPopup(args.CellRect, restype);
                    }
                    else
                    {
                        //EditorGUIUtility.FindTexture(AssetTreeManager.mIns.GetIconName("Folder"))
                        GUI.Label(args.CellRect, new GUIContent("ab", "Asset Bundle"));
                    }
                }
                else if (topmenutype == TopMenu.Size)//size
                {
                    long size = AssetBundleEditorHelper.GetAssetSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.FileSize)//file size
                {
                    long size = AssetBundleEditorHelper.GetFileSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.SelfSize)//size
                {
                    long size = AssetBundleEditorHelper.GetSelfAssetSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.SelfFileSize)//file size
                {
                    long size = AssetBundleEditorHelper.GetSelfFileSize(ref data, isroot, _model);

                    GUI.Label(args.CellRect, AssetBundleEditorHelper.ConvertSize(size));
                }
                else if (topmenutype == TopMenu.Dependency) //dependencies
                {
                    if (!isroot)
                    {
                        if (runtimeInfo.DependenciesCnt == 0)
                        {
                            GUI.enabled = false;
                        }
                        if (GUI.Button(args.CellRect, new GUIContent(runtimeInfo.DependenciesCnt.ToString())))
                        {
                            if (EditorContexts.mIns.Mode != AssetWindow.WindowMode.AssetDependency ||
                                !_selectfile.Equals(runtimeInfo.UnityPath) || EditorContexts.mIns.GuiContext.SelectDepth != 0)
                            {
                                _selectfile = runtimeInfo.UnityPath;
                                AssetTreeData selectData;
                                if (_model.GetItem(runtimeInfo.UnityPath, out selectData))
                                {
                                    EditorContexts.mIns.SelectForDependencyData = selectData;
                                }

                                EditorContexts.mIns.GuiContext.SelectDepth = 0;
                                if (EditorContexts.mIns.Mode != AssetWindow.WindowMode.AssetDependency)
                                {
                                    EditorContexts.mIns.Mode = AssetWindow.WindowMode.AssetDependency;
                                }
                                else
                                {
                                    EditorContexts.mIns.ForceModeChange(AssetWindow.WindowMode.AssetDependency);
                                }
                            }
                            else
                            {
                                EditorContexts.mIns.Mode = AssetWindow.WindowMode.Asset;
                            }
                            //_treeView.FrameItem(item.id);

                            var selectedIDs = new List <int>();
                            selectedIDs.Add(item.id);

                            _treeView.SetSelection(selectedIDs, TreeViewSelectionOptions.RevealAndFrame);
                        }

                        if (runtimeInfo.DependenciesCnt == 0)
                        {
                            GUI.enabled = true;
                        }
                    }
                }
                else if (topmenutype == TopMenu.BeDepend)
                {
                    if (!isroot)
                    {
                        var list = _model.GetDependParents(runtimeInfo.UnityPath);
                        if (list.Count == 0)
                        {
                            GUI.enabled = false;
                        }
                        if (GUI.Button(args.CellRect, list.Count.ToString()))
                        {
                            if (EditorContexts.mIns.Mode != AssetWindow.WindowMode.AssetDependency ||
                                !_selectfile.Equals(runtimeInfo.UnityPath) || EditorContexts.mIns.GuiContext.SelectDepth != 1)
                            {
                                _selectfile = runtimeInfo.UnityPath;
                                AssetTreeData selectData;
                                if (_model.GetItem(runtimeInfo.UnityPath, out selectData))
                                {
                                    EditorContexts.mIns.SelectForDependencyData = selectData;
                                }

                                EditorContexts.mIns.GuiContext.SelectDepth = 1;
                                if (EditorContexts.mIns.Mode != AssetWindow.WindowMode.AssetDependency)
                                {
                                    EditorContexts.mIns.Mode = AssetWindow.WindowMode.AssetDependency;
                                }
                                else
                                {
                                    EditorContexts.mIns.ForceModeChange(AssetWindow.WindowMode.AssetDependency);
                                }
                            }
                            else
                            {
                                EditorContexts.mIns.Mode = AssetWindow.WindowMode.Asset;
                            }
                            //_treeView.FrameItem(item.id);
                            var selectedIDs = new List <int>();
                            selectedIDs.Add(item.id);

                            _treeView.SetSelection(selectedIDs, TreeViewSelectionOptions.RevealAndFrame);
                        }
                        GUI.enabled = true;
                        ListPool <AssetTreeData> .Release(list);
                    }
                }
                else if (topmenutype == TopMenu.Info) //info
                {
                    GUI.skin.label.richText = true;
                    if (!isroot)
                    {
                        string info = AssetBundleEditorHelper.GetColorText(" Path :{0}", Color.yellow, runtimeInfo.UnityPath);

                        GUI.Label(args.CellRect, info);
                    }
                    else
                    {
                        string info = string.Format("Path:{0}", runtimeInfo.UnityPath);
                        info += AssetBundleEditorHelper.GetColorText(" Hash :{0}", Color.grey, runtimeInfo.HashCode);
                        info += AssetBundleEditorHelper.GetColorText(" Crc :{0}", Color.white, runtimeInfo.Crc);

                        if (HasNoAssetBundleName(ref data))
                        {
                            GUI.Label(args.CellRect, new GUIContent(info, AssetTreeManager.mIns.GetEditorTexture("warning")));
                        }
                        else
                        {
                            GUI.Label(args.CellRect, info);
                        }
                    }
                    GUI.skin.label.richText = false;
                }
                return(true);
            }
            return(false);
        }