Exemplo n.º 1
0
        private static AssetPackConfig BuildAssetBundles()
        {
            AssetDatabase.Refresh();

            var builds = _assetBundleNameToAssetGuid.Select(bundleAndGuid => new AssetBundleBuild
            {
                assetBundleName = bundleAndGuid.Key,
                assetNames      = new[] { AssetDatabase.GUIDToAssetPath(bundleAndGuid.Value) }
            }).ToArray();

            return(AssetBundleBuilder.BuildAssetBundles(AssetBundleDirectory, builds, AssetPackDeliveryMode.OnDemand,
                                                        null, BuildAssetBundleOptions.UncompressedAssetBundle, true));
        }
    private static void DoBuildAssetBundles()
    {
        var abPath = Application.streamingAssetsPath;

        if (Directory.Exists(abPath))
        {
            Directory.Delete(abPath, true);
        }
        if (!Directory.Exists(abPath))
        {
            Directory.CreateDirectory(abPath);
        }

        var builder = new AssetBundleBuilder();

        builder.AddSceneBundle("Assets/Scenes/Test.unity", "scenes_");
        builder.AddSceneBundle("Assets/Scenes/Loading.unity", "scenes_");
        builder.AddDirBundle("Assets/Textures/Dynamic", "", "textures_");
        builder.UpdateSharedAssets();
        builder.BuildAssetBundles(abPath, BuildAssetBundleOptions.ChunkBasedCompression,
                                  EditorUserBuildSettings.activeBuildTarget);
    }