Ejemplo n.º 1
0
        private void CreateVersionPackage()
        {
            Resources.UnloadUnusedAssets();

            string lasetManifestPath = Path.Combine(versionUpdatePath, lastManifestFolder);
            string assetBundlesPath  = Path.Combine(versionUpdatePath, assetBundlesFolder);
            string publishPath       = Path.Combine(versionUpdatePath, publishFolder);

            AssetBundleManifest newManifest;

            if (!LoadAssetBundleAsset(assetBundlesPath, out newManifest))
            {
                Debug.LogWarning("Load Asset Bundle Manifest Failed! " + assetBundlesPath);
                return;
            }

            if (!LoadAssetBundleAsset(assetBundlesPath, out versionData))
            {
                Debug.LogWarning("Load Version Update Data Failed!" + assetBundlesPath);
                return;
            }

            string zipName = versionData.versionNumber + ".zip";

            string[] newBundles = newManifest.GetAllAssetBundles();
            WriteVersionUpdateTable(publishPath, versionData.versionNumber, zipName);
            ZipUtility.CompressesFileList(assetBundlesPath, newBundles, string.Empty, Path.Combine(publishPath, zipName));
            if (copyToLastManifest)
            {
                CopyAssetBundleManifestToOldPath(assetBundlesPath, lasetManifestPath);
            }
            hasPackageVersion = true;
            Debug.Log("Create Version Package Successful!");
            EditorUtility.RevealInFinder(publishPath);
        }
Ejemplo n.º 2
0
        private void GenerateIncrementalPackage()
        {
            string manifestBundleName = typeof(AssetBundleManifest).Name;

            Resources.UnloadUnusedAssets();

            string lasetManifestPath = Path.Combine(versionUpdatePath, lastManifestFolder);
            string assetBundlesPath  = Path.Combine(versionUpdatePath, assetBundlesFolder);
            string publishPath       = Path.Combine(versionUpdatePath, publishFolder);

            AssetBundleManifest lastManifest;

            if (!LoadAssetBundleAsset(lasetManifestPath, out lastManifest))
            {
                Debug.LogWarning("Load last AssetBundleManifest Failed! " + lasetManifestPath);
                return;
            }

            AssetBundleManifest newManifest;

            if (!LoadAssetBundleAsset(assetBundlesPath, out newManifest))
            {
                Debug.LogWarning("Load AssetBundleManifest Failed! " + assetBundlesPath);
                return;
            }

            if (!LoadAssetBundleAsset(assetBundlesPath, out versionData))
            {
                Debug.LogWarning("Load Version Update Data Failed!" + assetBundlesPath);
                return;
            }

            List <string> addList    = new List <string>();
            List <string> removeList = new List <string>();

            string[] newBundles = newManifest.GetAllAssetBundles();
            string[] oldBundles = lastManifest.GetAllAssetBundles();
            foreach (string bundleName in newBundles)
            {
                if (ArrayUtility.Contains(oldBundles, bundleName))
                {
                    if (newManifest.GetAssetBundleHash(bundleName) == lastManifest.GetAssetBundleHash(bundleName))
                    {
                        continue;
                    }
                }
                addList.Add(bundleName);
            }
            foreach (string bundleName in oldBundles)
            {
                if (!ArrayUtility.Contains(newBundles, bundleName))
                {
                    removeList.Add(bundleName);
                }
            }

            if (addList.Count > 0)
            {
                string zipName = versionData.versionNumber + ".zip";
                WriteVersionUpdateTable(publishPath, versionData.versionNumber, zipName);
                ZipUtility.CompressesFileList(assetBundlesPath, addList.ToArray(), string.Empty, Path.Combine(publishPath, zipName));
                if (copyToLastManifest)
                {
                    CopyAssetBundleManifestToOldPath(assetBundlesPath, lasetManifestPath);
                }
                hasPackageVersion = true;
                Debug.Log("Generate Incremental Package Successful!");
            }
            else
            {
                Debug.Log("No Incremental Package Generate!");
            }

            EditorUtility.RevealInFinder(publishPath);
        }