Пример #1
0
 string GetSprInfo(ref SimpleSpriteInfo sprData)
 {
     return(string.Format("PackingTag:{0} MipMap:{1} BundleName:{2} Path:{3}",
                          sprData.PackingTag,
                          AssetBundleEditorHelper.GetColorText("{0}", Color.yellow, sprData.Mipmap),
                          AssetBundleEditorHelper.GetColorText("{0}", Color.blue, sprData.BundleName),
                          AssetBundleEditorHelper.GetColorText("{0}", Color.gray, sprData.AssetPath)));
 }
Пример #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
        //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);
        }
Пример #4
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);
            }
        }
Пример #5
0
        void RenderInfo()
        {
            var style = GUI.skin.FindStyle("flow node 2");

            style.alignment = TextAnchor.UpperLeft;
            //GUI.BeginGroup(EditorContexts.mIns.BuildInfoRect);

            using (var scope = new EditorGUILayout.VerticalScope())
            {
                GUILayout.BeginArea(EditorContexts.mIns.GuiContext.BuildInfoRect);
                _scrollpos = GUILayout.BeginScrollView(_scrollpos);

                var col = GUI.skin.label.normal.textColor;

                GUI.skin.label.normal.textColor = Color.white;
                GUI.skin.label.richText         = true;

                var allassetnames = AssetDatabase.GetAllAssetBundleNames();
                GUILayout.Label(string.Format("Will Build {0} AsseetBundles\n", AssetBundleEditorHelper.GetColorText("{0}", Color.red, allassetnames.Length)));

                var currenttarget = EditorUserBuildSettings.activeBuildTarget;
                GUILayout.Label(string.Format("Build Target:{0}\n", AssetBundleEditorHelper.GetColorText("{0}", Color.yellow, currenttarget)));

                GUILayout.Label(string.Format("BuildOption:{0}\n", AssetBundleEditorHelper.GetColorText("{0}", Color.yellow, GetOptionInfo())));

                GUILayout.Label(AssetBundleEditorHelper.GetColorText("{0}", Color.cyan, "AssetBundleOption Helper:\n"));

                GUILayout.Label("UncompressedAssetBundle:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                  "This bundle option builds the bundles in such a way that the data is completely uncompressed. The downside to being uncompressed is the larger file download size. However, the load times once downloaded will be much faster."));

                GUILayout.Label("DisableWriteTypeTree:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                               "Do not include type information within the AssetBundle."));

                GUILayout.Label("DeterministicAssetBundle:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                   "Builds an asset bundle using a hash for the id of the object stored in the asset bundle.When building the asset bundle with this method, the objects in it are assigned a 32 bit hash code that is calculated using the name of the asset bundle file, \n\tthe GUID of the asset and the local id of the object in the asset.For that reason make sure to use the same file name when rebuilding. \n\tAlso note that having a lot of objects might cause hash collisions preventing Unity from building the asset bundle."));

                GUILayout.Label("ForceRebuildAssetBundle:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                  "Force rebuild the assetBundles"));

                GUILayout.Label("IgnoreTypeTreeChanges:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                "Ignore the type tree changes when doing the incremental build check."));


                GUILayout.Label("AppendHashToAssetBundleName:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                      "Append the hash to the assetBundle name."));

                GUILayout.Label("ChunkBasedCompression:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                                " This bundle option uses a compression method known as LZ4, which results in larger compressed file sizes than LZMA but does not require that entire bundle is decompressed,\n\tunlike LZMA, before it can be used. LZ4 uses a chunk based algorithm which allows the AssetBundle be loaded in pieces or “chunks.”\n\tDecompressing a single chunk allows the contained assets to be used even if the other chunks of the AssetBundle are not decompressed."));

                GUILayout.Label("StrictMode:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                     "Do not allow the build to succeed if any errors are reporting during it."));

                GUILayout.Label("DryRunBuild:" + AssetBundleEditorHelper.GetColorText("{0}\n", Color.yellow,
                                                                                      "Do a dry run build.."));


                GUI.skin.label.richText         = false;
                GUI.skin.label.normal.textColor = col;

                GUILayout.EndScrollView();
                GUILayout.EndArea();
            }
        }