Esempio n. 1
0
        void AddFiles(BundleTreeItem folderItem)
        {
            string[] files = Directory.GetFiles(folderItem.path);
            foreach (string filePath in files)
            {
                G.Module.DisplayProgressBar(string.Format("PackageManager(检查:{1},载入总数:{0})",
                                                          loadFileProgressCount, G.Module.ModuleConfig.Json.CheckBundle), filePath,
                                            (float)loadFileProgressCount % 100000 / 100000);

                loadFileProgressCount++;

                //Texture2D cachedIcon = AssetDatabase.GetCachedIcon(filePath) as Texture2D; //TODO:如何找到类似函数
                if (filePath.EndsWith(".manifest", StringComparison.Ordinal))
                {
                    string bundlePath = filePath.Remove(filePath.Length - 9, 9);
                    string bundleName = Path.GetFileName(bundlePath);
                    var    fileItem   = new BundleTreeItem()
                    {
                        isFolder     = false,
                        verify       = true,
                        path         = filePath,                 //manifest文件路径
                        relativePath = bundlePath.Remove(0, G.Module.GetBundleFolderPathStrCount()).Replace('\\', '/'),
                        bundlePath   = bundlePath,               //去掉manifest后缀的完整路径
                        displayName  = bundleName,
                        icon         = bundleIcon,
                        id           = ++fileLastID,
                        size         = -1,
                        style        = labelBundleStyle
                    };
                    folderItem.AddChild(fileItem);
                    bundleDic.Add(fileItem.relativePath, fileItem);
                    //检查manifest对应文件是否存在
                    if (G.Module.ModuleConfig.Json.CheckBundle)
                    {
                        fileItem.verify = File.Exists(bundlePath);
                        if (fileItem.verify == false)
                        {
                            checkFailedItems.Add(fileItem);
                            fileItem.style = labelWarningStyle;
                        }
                    }
                    //----------------------------
                }
            }
        }
Esempio n. 2
0
 void AddDirectories(BundleTreeItem parent)
 {
     string[] directories = Directory.GetDirectories(parent.path);
     foreach (string path in directories)
     {
         var folderItem = new BundleTreeItem()
         {
             id           = --directoryLastID,
             displayName  = Path.GetFileName(path),
             isFolder     = true,
             path         = path,
             relativePath = path.Remove(0, G.Module.GetBundleFolderPathStrCount()).Replace('\\', '/'),
             icon         = folderIcon
         };
         parent.AddChild(folderItem);
         AddDirectories(folderItem);
         AddFiles(folderItem);
         folderDic.Add(folderItem.relativePath, folderItem);
     }
 }
Esempio n. 3
0
        private TreeViewItem BuildBundleTreeFromConfig()
        {
            if (string.IsNullOrEmpty(BundleConfigPath))
            {
                BundleTreeItem root = new BundleTreeItem()
                {
                    id          = 0,
                    depth       = -1,
                    displayName = "Root",
                    isFolder    = false,
                };
                return(root);
            }

            BundleTreeItem rootFolderItem = new BundleTreeItem()
            {
                id           = 0,
                depth        = -1,
                displayName  = "Root",
                isFolder     = true,
                relativePath = "", //这里是相对路径的根
                icon         = folderIcon
            };

            AssetBundleBuild[] bundles = JsonConvert.DeserializeObject <AssetBundleBuild[]>(File.ReadAllText(BundleConfigPath));
            foreach (var bundleItem in bundles)
            {
                BundleTreeItem currentFolderItem = rootFolderItem;
                BundleTreeItem folderItem;
                string[]       folders    = bundleItem.assetBundleName.Split('/');
                string         bundleName = folders[folders.Length - 1];
                for (int i = 0; i < folders.Length - 1; i++)
                {
                    string folderName = folders[i];
                    folderItem = null;
                    if (currentFolderItem.hasChildren)
                    {
                        folderItem = (BundleTreeItem)currentFolderItem.children.Find(x => x.displayName == folderName); //x.id <= 0 说明该项为文件夹
                    }
                    if (folderItem == null)
                    {
                        folderItem = new BundleTreeItem()
                        {
                            id           = --directoryLastID,
                            displayName  = folderName,
                            isFolder     = true,
                            relativePath = currentFolderItem.relativePath == "" ? folderName : currentFolderItem.relativePath + "/" + folderName,
                            icon         = folderIcon
                        };
                        currentFolderItem.AddChild(folderItem);
                        folderDic.Add(folderItem.relativePath, folderItem);
                    }
                    currentFolderItem = folderItem;
                }
                var fileItem = new BundleTreeItem()
                {
                    isFolder     = false,
                    verify       = true,
                    path         = null,
                    relativePath = bundleItem.assetBundleName,
                    bundlePath   = null,
                    displayName  = bundleName,
                    icon         = bundleIcon,
                    id           = ++fileLastID,
                    size         = -1,
                    style        = labelBundleStyle
                };
                currentFolderItem.AddChild(fileItem);
                bundleDic.Add(fileItem.relativePath, fileItem);
            }
            //加入虚拟的assetbundlemanifest
            var assetbundlemanifest = new BundleTreeItem()
            {
                isFolder     = false,
                verify       = true,
                path         = null,
                relativePath = "assetbundlemanifest",
                bundlePath   = null,
                displayName  = "assetbundlemanifest",
                icon         = bundleIcon,
                id           = ++fileLastID,
                size         = -1,
                style        = labelBundleStyle
            };

            rootFolderItem.AddChild(assetbundlemanifest);
            bundleDic.Add(assetbundlemanifest.relativePath, assetbundlemanifest);

            SetupDepthsFromParentsAndChildren(rootFolderItem);
            return(rootFolderItem);
        }