Esempio n. 1
0
        internal static CompatibilityAssetBundleManifest BuildAssetBundles_Internal(string outputPath, IBundleBuildContent content, BuildAssetBundleOptions options, BuildTarget targetPlatform)
        {
            var group      = BuildPipeline.GetBuildTargetGroup(targetPlatform);
            var parameters = new BundleBuildParameters(targetPlatform, group, outputPath);

            if ((options & BuildAssetBundleOptions.ForceRebuildAssetBundle) != 0)
            {
                parameters.UseCache = false;
            }

            if ((options & BuildAssetBundleOptions.AppendHashToAssetBundleName) != 0)
            {
                parameters.AppendHash = true;
            }

#if UNITY_2018_3_OR_NEWER
            if ((options & BuildAssetBundleOptions.ChunkBasedCompression) != 0)
            {
                parameters.BundleCompression = BuildCompression.LZ4;
            }
            else if ((options & BuildAssetBundleOptions.UncompressedAssetBundle) != 0)
            {
                parameters.BundleCompression = BuildCompression.Uncompressed;
            }
            else
            {
                parameters.BundleCompression = BuildCompression.LZMA;
            }
#else
            if ((options & BuildAssetBundleOptions.ChunkBasedCompression) != 0)
            {
                parameters.BundleCompression = BuildCompression.DefaultLZ4;
            }
            else if ((options & BuildAssetBundleOptions.UncompressedAssetBundle) != 0)
            {
                parameters.BundleCompression = BuildCompression.DefaultUncompressed;
            }
            else
            {
                parameters.BundleCompression = BuildCompression.DefaultLZMA;
            }
#endif

            if ((options & BuildAssetBundleOptions.DisableWriteTypeTree) != 0)
            {
                parameters.ContentBuildFlags |= ContentBuildFlags.DisableWriteTypeTree;
            }

            IBundleBuildResults results;
            ReturnCode          exitCode = ContentPipeline.BuildAssetBundles(parameters, content, out results);
            if (exitCode < ReturnCode.Success)
            {
                return(null);
            }

            var manifest = ScriptableObject.CreateInstance <CompatibilityAssetBundleManifest>();
            manifest.SetResults(results.BundleInfos);
            File.WriteAllText(parameters.GetOutputFilePathForIdentifier(Path.GetFileName(outputPath) + ".manifest"), manifest.ToString());
            return(manifest);
        }
Esempio n. 2
0
        internal static LegacyAssetBundleManifest BuildAssetBundles_Internal(string outputPath, IBundleBuildContent content, BuildAssetBundleOptions options, BuildTarget targetPlatform)
        {
            var group      = BuildPipeline.GetBuildTargetGroup(targetPlatform);
            var parameters = new BundleBuildParameters(targetPlatform, group, outputPath);

            if ((options & BuildAssetBundleOptions.ForceRebuildAssetBundle) != 0)
            {
                parameters.UseCache = false;
            }

#if UNITY_2018_3_OR_NEWER
            if ((options & BuildAssetBundleOptions.ChunkBasedCompression) != 0)
            {
                parameters.BundleCompression = BuildCompression.LZ4;
            }
            else if ((options & BuildAssetBundleOptions.UncompressedAssetBundle) != 0)
            {
                parameters.BundleCompression = BuildCompression.Uncompressed;
            }
            else
            {
                parameters.BundleCompression = BuildCompression.LZMA;
            }
#else
            if ((options & BuildAssetBundleOptions.ChunkBasedCompression) != 0)
            {
                parameters.BundleCompression = BuildCompression.DefaultLZ4;
            }
            else if ((options & BuildAssetBundleOptions.UncompressedAssetBundle) != 0)
            {
                parameters.BundleCompression = BuildCompression.DefaultUncompressed;
            }
            else
            {
                parameters.BundleCompression = BuildCompression.DefaultLZMA;
            }
#endif

            if ((options & BuildAssetBundleOptions.DisableWriteTypeTree) != 0)
            {
                parameters.ContentBuildFlags |= ContentBuildFlags.DisableWriteTypeTree;
            }

            IBundleBuildResults results;
            ReturnCode          exitCode = ContentPipeline.BuildAssetBundles(parameters, content, out results);
            if (exitCode < ReturnCode.Success)
            {
                return(null);
            }

            return(new LegacyAssetBundleManifest(results));
        }