Exemple #1
0
 public void Update()
 {
     if (AssetMode.Update())
     {
         Reload();
     }
 }
Exemple #2
0
        void CreateResGroup(object context)
        {
            string name = AssetMode.HandleGroupCreate();

            ReloadAndSelect(new List <int>());
            var item = rootItem.children.Find(a => a.displayName == name);

            BeginRename(item);
        }
        public static AssetMoveResult OnWillMoveAsset(string oldPath, string newPath)
        {
            AssetMoveResult result = AssetMoveResult.DidNotMove;

            if (!oldPath.Contains("/Resources/") && !oldPath.Contains(ResConfig.ExternalResDir))
            {
                result = AssetMoveResult.DidNotMove;
                return(result);
            }

            AssetMode.Rebuild();
            var isSaveRes = CheckIsResPath(oldPath);
            var isFolder  = Directory.Exists(oldPath);

            if (isSaveRes)
            {
                if (!newPath.Contains("/Resources/") && !newPath.Contains(ResConfig.ExternalResDir))
                {
                    result = AssetMoveResult.FailedMove;
                }

                if (!isFolder && newPath.Contains(ResConfig.ExternalResDir) &&
                    Path.GetDirectoryName(newPath).Replace("\\", "/") == ResConfig.ExternalResDir)
                {
                    result = AssetMoveResult.FailedMove;
                }

                if (result == AssetMoveResult.FailedMove)
                {
                    UnityEditor.EditorUtility.DisplayDialog("tips", "移动路径不符合规范", "确定");
                }
                else
                {
                    if (UnityEditor.EditorUtility.DisplayDialog("tips", "此资源已经被添加至了资源编辑器,改变后会自动修改\n 确定要修改吗?", "确定"))
                    {
                        if (isFolder)
                        {
                            MoveFolder(oldPath, newPath);
                        }
                        else
                        {
                            ChangeAssetInfo(oldPath, newPath);
                        }
                    }
                    else
                    {
                        result = AssetMoveResult.FailedMove;
                    }
                }
            }
            else
            {
                result = AssetMoveResult.DidNotMove;
            }

            return(result);
        }
Exemple #4
0
        private void Update()
        {
            if (Time.realtimeSinceStartup - m_UpdateDelay > 0.1f)
            {
                m_UpdateDelay = Time.realtimeSinceStartup;

                if (AssetMode.Update())
                {
                    Repaint();
                }
            }
        }
Exemple #5
0
        public ResGroupTreeEditor(TreeViewState state, AssetGroupMgr ctrl, MultiColumnHeaderState mchs) : base(state,
                                                                                                               new MultiColumnHeader(mchs))
        {
            showBorder = true;

            showAlternatingRowBackgrounds = false;
            //DefaultStyles.label.richText = true;
            AssetMode.Rebuild();
            mController = ctrl;
            Refresh();
            Reload();
        }
Exemple #6
0
        void RemoveAssets(object obj)
        {
            List <AssetTreeViewItem> list     = obj as List <AssetTreeViewItem>;
            List <string>            reAssets = new List <string>();

            foreach (AssetTreeViewItem item in list)
            {
                reAssets.Add(item.asset.data.address);
            }

            AssetMode.RemoveAssets(reAssets, groupName);
            RelodGroup(groupName);
        }
Exemple #7
0
        public void OnEnable(Rect pos, EditorWindow parent)
        {
            m_Parent   = parent;
            m_Position = pos;
            m_HorizontalSplitterRect = new Rect(
                (int)(m_Position.x + m_Position.width * m_HorizontalSplitterPercent),
                m_Position.y,
                k_SplitterWidth,
                m_Position.height);

            m_VerticalSplitterRect = new Rect(
                m_HorizontalSplitterRect.x,
                (int)(m_Position.y + m_HorizontalSplitterRect.height * m_VerticalSplitterPercent),
                (m_Position.width - m_HorizontalSplitterRect.width) - k_SplitterWidth,
                k_SplitterWidth);
            if (mAssetsBundleAssetsTree == null)
            {
                m_AssetListState = new TreeViewState();
                var assetHeaderState = AssetsBundleAssetsTree.CreateDefaultMultiColumnHeaderState();
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_AssetListMCHState, assetHeaderState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_AssetListMCHState, assetHeaderState);
                }

                m_AssetListMCHState     = assetHeaderState;
                mAssetsBundleAssetsTree = new AssetsBundleAssetsTree(m_AssetListState, m_AssetListMCHState);
            }
            if (mAssetBundleNameTree == null)
            {
                m_GroupTreeState = new TreeViewState();

                var headerState = AssetBundleNameTree.CreateDefaultMultiColumnHeaderState(); //
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_GroupTreeMCHState, headerState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_GroupTreeMCHState, headerState);
                }
                m_GroupTreeMCHState  = headerState;
                mAssetBundleNameTree = new AssetBundleNameTree(mAssetsBundleAssetsTree, m_GroupTreeState, m_GroupTreeMCHState);
            }



            if (mAssetBuildView == null)
            {
                mAssetBuildView = new AssetBuildView();
            }
            AssetMode.Rebuild();
            mAssetBuildView.Reload();
            mAssetBundleNameTree.Reload();
            mAssetsBundleAssetsTree.Reload();
        }
Exemple #8
0
        void DeleteGroups(object b)
        {
            var selectedNodes = b as List <int>;
            var names         = new List <string>();

            foreach (var id  in selectedNodes)
            {
                names.Add(FindItem(id, rootItem).displayName);
            }

            AssetMode.HandleGroupsDelete(names);
            ReloadAndSelect(new List <int>());
            mController.UpdateSelectedGroup(string.Empty);
        }
Exemple #9
0
        public static void BuildAll(string ver, string outPath, BuildTarget target, BuildAssetBundleOptions options)
        {
            AssetMode.Rebuild();
            var    buils       = BuildSelect(outPath, AssetMode.GetAllBundleNames(), target, options);
            string newFileName = outPath + "/" + Path.GetFileName(ResConfig.ResJsonCfgFilePath);

            if (File.Exists(newFileName))
            {
                File.Delete(newFileName);
            }
            File.Copy(ResConfig.ResJsonCfgFilePath, newFileName, true);
            BuildABVersionInfo(outPath, ver, buils);
            GC.Collect();
            Resources.UnloadUnusedAssets();
            AssetDatabase.Refresh();
        }
        private static void DelAssset(string path)
        {
            var resInfoData = AssetMode.resInfo.resources.Find(a => a.path == path);

            if (resInfoData == null)
            {
                Debug.LogError("不能删除不存在的资源" + path);
            }
            else
            {
                var group = AssetMode.resInfo.groups.Find(a => a.keys.Contains(resInfoData.address));
                group.keys.Remove(resInfoData.address);
                AssetMode.resInfo.resources.Remove(resInfoData);
                AssetMode.Update();
            }
        }
Exemple #11
0
        protected override TreeViewItem BuildRoot()
        {
            mRoot          = new TreeViewItem();
            mRoot.id       = -1;
            mRoot.depth    = -1;
            mRoot.children = new List <TreeViewItem>();
            int id = 0;

            foreach (string name in AssetMode.GetAllBundleNames())
            {
                id++;
                var t = new TreeViewItem(id, id, name);
                mRoot.AddChild(t);
            }

            return(mRoot);
        }
        private static void ChangeAssetInfo(string oldPath, string newPath)
        {
            var resInfo = AssetMode.resInfo.resources.Find(a => a.path == oldPath);

            resInfo.path = newPath;
            var rootPath = Path.GetDirectoryName(newPath);

            rootPath = rootPath.Replace("\\", "/");
            var    name1  = Path.GetFileName(newPath);
            string abName = string.Empty;
            string url    = string.Empty;

            resInfo.isResourcesPath = newPath.Contains("/Resources/");
            if (rootPath != null)
            {
                if (resInfo.isResourcesPath)
                {
                    int index = rootPath.LastIndexOf("/Resources", StringComparison.Ordinal);
                    if (rootPath.Length <= index + 11)
                    {
                        abName = string.Empty;
                        url    = "r://" + name1;
                    }
                    else
                    {
                        abName = rootPath.Substring(index + 11);
                        url    = "r://" + abName + "/" + name1;
                    }
                }
                else
                {
                    var path1 = rootPath.Replace(ResConfig.ExternalResDir + "/", "");
                    ;
                    url    = "e://" + path1 + "/" + name1;
                    abName = path1.Replace("/", "_");
                }
            }

            resInfo.path   = newPath;
            resInfo.ABName = abName;
            resInfo.url    = url;
            AssetMode.Update();
        }
Exemple #13
0
        /// <summary>
        /// 更改名称完成
        /// </summary>
        /// <param name="args"></param>
        protected override void RenameEnded(RenameEndedArgs args)
        {
            //base.RenameEnded(args);

            if (!string.IsNullOrEmpty(args.newName) && args.newName != args.originalName)
            {
                args.acceptedRename = AssetMode.HandleGroupRename(args.originalName, args.newName);
                if (args.acceptedRename)
                {
                    Reload();
                    mController.UpdateSelectedGroup(args.newName);
                    //ReloadAndSelect(args.itemID, false);
                }
            }
            else
            {
                args.acceptedRename = false;
            }
        }
Exemple #14
0
        public void SelectAB(string abName)
        {
            this.assets.Clear();
            if (string.IsNullOrEmpty(abName))
            {
                Reload();
                return;
            }
            var assets = AssetMode.getABAssets(abName);
            int id     = 0;

            foreach (var a in assets)
            {
                id++;
                AssetMode.AssetInfo assetInfo = new AssetMode.AssetInfo(id, a.address);
                //assetInfo.data = a;
                this.assets.Add(assetInfo);
            }
            Reload();
        }
Exemple #15
0
        /// <summary>
        /// 有东西被拖动到了这
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        protected override DragAndDropVisualMode HandleDragAndDrop(DragAndDropArgs args)
        {
            if (IsValidDragDrop(args))
            {
                if (args.performDrop)
                {
                    List <string> name = AssetMode.AddAssetToGroup(DragAndDrop.paths, groupName);
                    foreach (string path in DragAndDrop.paths)
                    {
                        Debug.Log("SetupDragAndDrop 2" + path);
                    }

                    AddAssetToGroup(name);
                }

                return(DragAndDropVisualMode.Copy); //Move;
            }


            return(DragAndDropVisualMode.Rejected);
        }
        private static AssetDeleteResult OnWillDeleteAsset(string assetPath, RemoveAssetOptions options)
        {
            AssetMode.Rebuild();
            AssetDeleteResult r = AssetDeleteResult.DidNotDelete;
            var isFolder        = Directory.Exists(assetPath);
            var isres           = CheckIsResPath(assetPath);

            if (isres)
            {
                if (UnityEditor.EditorUtility.DisplayDialog("tips", "此资源已经被添加至了资源编辑器,删除后将会从管理器中移除\n 确定要删除吗?", "确定"))
                {
                    DelAssset(assetPath);
                }
                else
                {
                    r = AssetDeleteResult.FailedDelete;
                }
            }

            return(r);
        }
Exemple #17
0
        public static List <AssetBundleBuild> BuildSelect(string outPath, List <string> abs, BuildTarget target, BuildAssetBundleOptions options)
        {
            var needAdds = new List <AssetBundleBuild>();

            foreach (var ab in abs)
            {
                List <ResInfoData> list = AssetMode.getABAssets(ab);
                if (list.Count > 0)
                {
                    var bs = new AssetBundleBuild();
                    bs.assetBundleName    = ab.ToLower();
                    bs.assetBundleVariant = "bytes";
                    List <string> assets = new List <string>();
                    foreach (var v in list)
                    {
                        if (!assets.Contains(v.path))
                        {
                            assets.Add(v.path);
                        }
                        Debug.Log("abname:" + v.ABName + "  /path:" + v.path);
                    }

                    bs.assetNames = assets.ToArray();
                    if (bs.assetNames.Length > 0)
                    {
                        needAdds.Add(bs);
                    }
                }
            }

            if (!Directory.Exists(outPath))
            {
                Directory.CreateDirectory(outPath);
            }
            BuildPipeline.BuildAssetBundles(outPath, needAdds.ToArray(), options, target);
            return(needAdds);
        }
Exemple #18
0
        /// <summary>
        /// 更改名称完成
        /// </summary>
        /// <param name="args"></param>
        protected override void RenameEnded(RenameEndedArgs args)
        {
            var item = FindItem(args.itemID, rootItem);

            currentSelect = -1;
            if (!string.IsNullOrEmpty(args.newName) && args.newName != args.originalName)
            {
                args.acceptedRename = AssetMode.HandleAssetRename(args.originalName, args.newName);
                ReloadAndSelect(new List <int>()
                {
                    args.itemID
                });
            }
            else
            {
                args.acceptedRename = false;
            }


            //base.RenameEnded(args);
//
//            if (args.newName != null && args.newName.Length > 0 && args.newName != args.originalName)
//            {
//                //args.newName = args.newName.ToLower();
//                args.acceptedRename = true;
//
//                args.acceptedRename = AssetMode.HandleGroupRename(args.originalName, args.newName);
//                if (args.acceptedRename)
//                {
//                    ReloadAndSelect(args.itemID, false);
//                }
//            }
//            else
//            {
//                args.acceptedRename = false;
//            }
        }
Exemple #19
0
        public void OnEnable(Rect pos, EditorWindow parent)
        {
            m_Parent   = parent;
            m_Position = pos;
            m_HorizontalSplitterRect = new Rect(
                (int)(m_Position.x + m_Position.width * m_HorizontalSplitterPercent),
                m_Position.y,
                k_SplitterWidth,
                m_Position.height);

            m_VerticalSplitterRect = new Rect(
                m_HorizontalSplitterRect.x,
                (int)(m_Position.y + m_HorizontalSplitterRect.height * m_VerticalSplitterPercent),
                (m_Position.width - m_HorizontalSplitterRect.width) - k_SplitterWidth,
                k_SplitterWidth);
            if (m_ResGroupTree != null)
            {
                m_ResGroupTree.Reload();
            }

            if (m_ResGroupTree != null)
            {
                m_ResGroupTree.Reload();
            }

            if (mAssetInfoEditor != null)
            {
                mAssetInfoEditor.Reload();
            }

            if (m_Parent != null)
            {
                m_Parent.Repaint();
            }
            AssetMode.Rebuild();
        }