コード例 #1
0
    static void BuildAllAssetBundles()
    {
        BundlePacker.DeleteAsset();

#if UNITY_ANDROID
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, BuildTarget.Android);
#elif UNITY_IOS
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, BuildTarget.iOS);
#elif UNITY_WEBGL
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, BuildTarget.WebGL);
#elif UNITY_STANDALONE_OSX
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, BuildTarget.StandaloneOSX);
#else
        BuildPipeline.BuildAssetBundles("Assets/StreamingAssets", BuildAssetBundleOptions.None, BuildTarget.StandaloneWindows64);
#endif
        BundlePacker.Modify();
        AssetDatabase.Refresh();
    }
コード例 #2
0
ファイル: PackageBuilder.cs プロジェクト: jiangzi/paradox
        private BuildResultCode BuildMaster()
        {
            // Only querying graphics platform, let's load package, print it and exit
            if (builderOptions.GetGraphicsPlatform)
            {
                return BuildGetGraphicsPlatform();
            }

            assetLogger = new RemoteLogForwarder(builderOptions.Logger, builderOptions.LogPipeNames);
            GlobalLogger.GlobalMessageLogged += assetLogger;
            PackageSession projectSession = null;
            try
            {
                // TODO handle solution file + package-id ?

                // When the current platform is not on windows, we need to make sure that all plugins are build, so we
                // setup auto-compile when loading the session
                var sessionLoadParameters = new PackageLoadParameters
                {
                    AutoCompileProjects = builderOptions.Platform != PlatformType.Windows || !builderOptions.DisableAutoCompileProjects,
                    ExtraCompileProperties = builderOptions.ExtraCompileProperties,
                };

                // Loads the root Package
                var projectSessionResult = PackageSession.Load(builderOptions.PackageFile, sessionLoadParameters);
                if (projectSessionResult.HasErrors)
                {
                    projectSessionResult.CopyTo(builderOptions.Logger);
                    return BuildResultCode.BuildError;
                }

                projectSession = projectSessionResult.Session;

                // Check build configuration
                var package = projectSession.LocalPackages.Last();

                // Check build profile
                var sharedProfile = package.Profiles.FindSharedProfile();
                var buildProfile = package.Profiles.FirstOrDefault(pair => pair.Name == builderOptions.BuildProfile);
                if (buildProfile == null)
                {
                    builderOptions.Logger.Error("Unable to find profile [{0}] in package [{1}]", builderOptions.BuildProfile, package.FullPath);
                    return BuildResultCode.BuildError;
                }

                // Setup variables
                var buildDirectory = builderOptions.BuildDirectory;
                var outputDirectory = builderOptions.OutputDirectory;

                // Process game settings asset
                var gameSettingsAsset = package.GetGameSettingsAsset();
                if (gameSettingsAsset == null)
                {
                    builderOptions.Logger.Warning("Could not find game settings asset at location [{0}]. Use a Default One", GameSettingsAsset.GameSettingsLocation);
                    gameSettingsAsset = new GameSettingsAsset();
                }

                // Create context
                var context = new AssetCompilerContext
                {
                    Profile = builderOptions.BuildProfile,
                    Platform = builderOptions.Platform
                };
                context.SetGameSettingsAsset(gameSettingsAsset);

                // Copy properties from shared profiles to context properties
                if (sharedProfile != null)
                {
                    sharedProfile.Properties.CopyTo(context.PackageProperties, true);
                }

                // Copy properties from build profile
                buildProfile.Properties.CopyTo(context.PackageProperties, true);

                // Builds the project
                var assetBuilder = new PackageCompiler(new RootPackageAssetEnumerator(package));
                assetBuilder.AssetCompiled += RegisterBuildStepProcessedHandler;

                var assetBuildResult = assetBuilder.Compile(context);
                assetBuildResult.CopyTo(builderOptions.Logger);
                if (assetBuildResult.HasErrors)
                    return BuildResultCode.BuildError;

                // Create the builder
                var indexName = "index." + builderOptions.BuildProfile;
                builder = new Builder(buildDirectory, builderOptions.BuildProfile, indexName, builderOptions.Logger) { ThreadCount = builderOptions.ThreadCount };
                builder.MonitorPipeNames.AddRange(builderOptions.MonitorPipeNames);

                // Add build steps generated by AssetBuilder
                builder.Root.Add(assetBuildResult.BuildSteps);

                // Run builder
                var result = builder.Run(Builder.Mode.Build);
                builder.WriteIndexFile(false);

                // Fill list of bundles
                var bundlePacker = new BundlePacker();
                bundlePacker.Build(builderOptions.Logger, projectSession, buildProfile, indexName, outputDirectory, builder.DisableCompressionIds);

                return result;
            }
            finally
            {
                if (builder != null)
                {
                    builder.Dispose();
                }

                // Dispose the session (in order to unload assemblies)
                if (projectSession != null)
                {
                    projectSession.Dispose();
                }

                // Flush and close logger
                GlobalLogger.GlobalMessageLogged -= assetLogger;
                assetLogger.Dispose();
            }
        }
コード例 #3
0
ファイル: PackageBuilder.cs プロジェクト: Powerino73/paradox
        private BuildResultCode BuildMaster()
        {
            assetLogger = new RemoteLogForwarder(builderOptions.Logger, builderOptions.LogPipeNames);
            GlobalLogger.GlobalMessageLogged += assetLogger;

            // TODO handle solution file + package-id ?

            // When the current platform is not on windows, we need to make sure that all plugins are build, so we
            // setup auto-compile when loading the session
            var sessionLoadParameters = new PackageLoadParameters
                {
                    AutoCompileProjects = builderOptions.Platform != PlatformType.Windows || builderOptions.ProjectConfiguration != "Debug", // Avoid compiling if Windows|Debug
                    ExtraCompileProperties = builderOptions.ExtraCompileProperties,
                };

            // Loads the root Package
            var projectSessionResult = PackageSession.Load(builderOptions.PackageFile, sessionLoadParameters);
            if (projectSessionResult.HasErrors)
            {
                projectSessionResult.CopyTo(builderOptions.Logger);
                return BuildResultCode.BuildError;
            }

            var projectSession = projectSessionResult.Session;

            // Check build configuration
            var package = projectSession.LocalPackages.First();

            // Check build profile
            var sharedProfile = package.Profiles.FindSharedProfile();
            var buildProfile = package.Profiles.FirstOrDefault(pair => pair.Name == builderOptions.BuildProfile);
            if (buildProfile == null)
            {
                builderOptions.Logger.Error("Unable to find profile [{0}] in package [{1}]", builderOptions.BuildProfile, package.FullPath);
                return BuildResultCode.BuildError;
            }

            // Setup variables
            var buildDirectory = builderOptions.BuildDirectory;
            var outputDirectory = builderOptions.OutputDirectory;

            // Builds the project
            var assetBuilder = new PackageCompiler();
            assetBuilder.AssetCompiled += RegisterBuildStepProcessedHandler;

            // Create context
            var context = new AssetCompilerContext
            {
                Package = package,
                Platform = builderOptions.Platform
            };

            // Copy properties from shared profiles to context properties
            if (sharedProfile != null)
            {
                foreach (var propertyValue in sharedProfile.Properties)
                    context.Properties.Set(propertyValue.Key, propertyValue.Value);
            }

            context.Properties.Set(Paradox.Assets.ParadoxConfig.GraphicsPlatform, builderOptions.GraphicsPlatform.HasValue ? builderOptions.GraphicsPlatform.Value : builderOptions.GetDefaultGraphicsPlatform());

            // Copy properties from build profile
            foreach (var propertyValue in buildProfile.Properties)
            {
                context.Properties.Set(propertyValue.Key, propertyValue.Value);
            }

            var assetBuildResult = assetBuilder.Compile(context);
            assetBuildResult.CopyTo(builderOptions.Logger);
            if (assetBuildResult.HasErrors)
                return BuildResultCode.BuildError;

            // Create the builder
            var indexName = "index." + builderOptions.BuildProfile;
            builder = new Builder(buildDirectory, builderOptions.BuildProfile, indexName, "InputHashes", builderOptions.Logger) { ThreadCount = builderOptions.ThreadCount };
            builder.MonitorPipeNames.AddRange(builderOptions.MonitorPipeNames);

            // Add build steps generated by AssetBuilder
            builder.Root.Add(assetBuildResult.BuildSteps);

            // Run builder
            var result = builder.Run(Builder.Mode.Build);
            builder.WriteIndexFile(false);

            // Fill list of bundles
            var bundlePacker = new BundlePacker();
            bundlePacker.Build(builderOptions.Logger, projectSession, buildProfile, indexName, outputDirectory, builder.DisableCompressionIds);

            // Flush and close logger
            GlobalLogger.GlobalMessageLogged -= assetLogger;
            assetLogger.Dispose();
            
            return result;
        }