예제 #1
0
        static async void LoadManifest()
        {
            var bundleName = BundleUtility.GetPlatformName();

            Debug.Log("Loading Asset Bundle Manifest: " + bundleName);
            var bundle = await LoadAssetBundleRaw(bundleName);

            var loadedBundle = new LoadedAssetBundle(new BundleMetadata(bundleName), bundle);
            var task         = new TaskCompletionSource <LoadedAssetBundle>(loadedBundle);

            AssetBundles.Add(bundleName, task);
            var request = await bundle.LoadAssetAsync <AssetBundleManifest>("AssetBundleManifest").ToTask();

            Manifest.SetResult(new BundleManfiestMap(request.asset as AssetBundleManifest));
        }
예제 #2
0
        public static void BuildAssetBundles(BuildTarget?target = null)
        {
            var buildTarget = target ?? EditorUserBuildSettings.activeBuildTarget;
            // Choose the output path according to the build target.
            string outputPath = Path.Combine(BundleUtility.AssetBundlesOutputPath, BundleUtility.GetPlatformName(target));

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            //@TODO: use append hash... (Make sure pipeline works correctly with it.)
            BuildPipeline.BuildAssetBundles(outputPath,
                                            BuildAssetBundleOptions.ChunkBasedCompression |
                                            BuildAssetBundleOptions.DeterministicAssetBundle |
                                            BuildAssetBundleOptions.StrictMode,
                                            buildTarget);
            CopyAssetBundlesTo(outputPath, Path.Combine(Application.streamingAssetsPath, BundleUtility.AssetBundlesOutputPath));
            AssetDatabase.Refresh();
        }
예제 #3
0
        public static void BuildPlayer()
        {
            var outputPath = EditorUtility.SaveFolderPanel("Choose Location of the Built Game", "", "");

            if (outputPath.Length == 0)
            {
                return;
            }

            string[] levels = GetLevelsFromBuildSettings();
            if (levels.Length == 0)
            {
                Debug.Log("Nothing to build.");
                return;
            }

            var    target     = EditorUserBuildSettings.activeBuildTarget;
            string targetName = GetBuildTargetName(target);

            if (targetName == null)
            {
                return;
            }

            // Build and copy AssetBundles.
            BuildAssetBundles();
            CopyAssetBundlesTo(Path.Combine(BundleUtility.AssetBundlesOutputPath, BundleUtility.GetPlatformName(target)),
                               Path.Combine(Application.streamingAssetsPath, BundleUtility.AssetBundlesOutputPath));
            AssetDatabase.Refresh();

            BuildOptions option = EditorUserBuildSettings.development ? BuildOptions.Development : BuildOptions.None;

            BuildPipeline.BuildPlayer(levels, outputPath + targetName, EditorUserBuildSettings.activeBuildTarget, option);
            if (Directory.Exists(outputPath))
            {
                foreach (var file in Directory.GetFiles(outputPath, "*.manifest", SearchOption.AllDirectories))
                {
                    File.Delete(file);
                }
            }
        }
예제 #4
0
 public static void SetSourceAssetBundleUrl(string absolutePath)
 {
     BaseDownloadingUrl = absolutePath + BundleUtility.GetPlatformName() + "/";
 }