Example #1
0
        public static void DoPostprocess(AssetBundleManifest buildManifest, AssetBundleBrowser.AssetBundleDataSource.ABBuildInfo info)
        {
            Resource.BundleList bundleList = new ZFramework.Resource.BundleList();
            bundleList.bundles = new List <Resource.BundleList.URLVersionPair>();

            foreach (var assetBundleName in buildManifest.GetAllAssetBundles())
            {
                bundleList.bundles.Add(new Resource.BundleList.URLVersionPair()
                {
                    bundleName  = assetBundleName,
                    bundleSize  = new FileInfo(info.outputDirectory + "/" + assetBundleName).Length,
                    hashCode    = buildManifest.GetAssetBundleHash(assetBundleName).GetHashCode(),
                    preDownload = true
                });
            }

            //保存BundleList
            System.Type jsonHelperType = Utility.Assembly.GetTypeWithinLoadedAssemblies("ZFramework.Runtime.JsonHelper");
            ZFramework.Utility.Json.IJsonHelper jsonHelper = (ZFramework.Utility.Json.IJsonHelper)Activator.CreateInstance(jsonHelperType);
            ZFramework.Utility.Json.SetJsonHelper(jsonHelper);
            string       json_bundleList = ZFramework.Utility.Json.ToJson(bundleList);
            StreamWriter fileWriter      = new StreamWriter(info.outputDirectory + "/BundleList.json");

            fileWriter.WriteLine(json_bundleList);
            fileWriter.Close();
            fileWriter.Dispose();
        }
Example #2
0
        public static void BuildBundleCompleted(AssetBundleBrowser.AssetBundleDataSource.ABBuildInfo buildInfo)
        {
            AssetDatabase.RemoveAssetBundleName(manifestName.ToLower(), true);
            string assetManifestName    = Path.Combine(buildInfo.outputDirectory, Path.GetFileName(buildInfo.outputDirectory));
            string newAssetManifestName = Path.Combine(buildInfo.outputDirectory, typeof(AssetBundleManifest).Name);

            if (File.Exists(newAssetManifestName))
            {
                File.Delete(newAssetManifestName);
            }
            if (File.Exists(newAssetManifestName + ".manifest"))
            {
                File.Delete(newAssetManifestName + ".manifest");
            }

            File.Move(assetManifestName, newAssetManifestName);
            File.Move(assetManifestName + ".manifest", newAssetManifestName + ".manifest");
            AssetDatabase.DeleteAsset(manifestAssetPath);

            Debug.Log("Build Bundles Completed.");
        }
Example #3
0
        public bool BuildAssetBundles(AssetBundleBrowser.AssetBundleDataSource.ABBuildInfo info)
        {
            AssetBundleBuildMap.GetBuildMap().Clear();

            UpdateGraphInfo();

            if (string.IsNullOrEmpty(m_graphGuid))
            {
                return(false);
            }

            string path = AssetDatabase.GUIDToAssetPath(m_graphGuid);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            var graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(path);

            Type infoType = info.GetType();

            var fieldInfo = infoType.GetField("buildTarget");

            if (fieldInfo != null)
            {
                BuildTarget target = (BuildTarget)fieldInfo.GetValue(info);
                var         result = AssetGraphUtility.ExecuteGraph(target, graph);
                if (result.IsAnyIssueFound)
                {
                    return(false);
                }
            }

            return(true);
        }