Asset Bundle support?

Hi guys, wondering if it’s currently possible to produce asset bundles via Cloud Build. If not, is this something on the roadmap?

I think the most flexible solution might be to allow command line parameters to be specified. Then we could specify an executeMethod parameter to call into custom build logic that would in turn invoke BuildPipeline.BuildAssetBundle().

Not sure how you’d get the bundle files out from the build, though. Perhaps you could have something like Shippable’s build artifact folder that gets zipped up automatically and made available for download. That way we could also do things like spit out unit test results, code coverage reports, or whatever.

I guess we could set up a Jenkins server to do this stuff, but Cloud Build seems way cooler… :slight_smile:

Cheers!

1 Like

@steve.salmond - yes, Asset Bundles are on our roadmap. We don’t have a date for when that will be ready, but it’s something we plan on doing.

For those of you who are interested in using Asset Bundles and find this discussion thread - please post any thoughts or ideas you might have for this feature request - thanks!

Thanks for the quick response!

The command line parameters idea is just one possibility I guess - you could also have a more specialized workflow that focuses just on bundle production. The latter would probably be more user friendly if it existed, assuming there was a convenient way to specify what content went into the bundle (perhaps specifying a folder and/or set of file extensions?), and a way to get at those bundles once they were built, or a way to deploy bundles directly (e.g. push to S3).

Looking forward to hearing how this develops. I’m sure you guys have a mighty big shopping list already, so no pressure… :slight_smile:

1 Like

Hi there, I’m also interested in producing asset bundles via unity cloud. How is it going with this feature?
Best, Flo

No updates yet. But you can write your own pre/post build scripts which generate the Asset Bundles for you and upload the output to a external storage.

1 Like

I was wondering if this could be used to produce AssetBundles at runtime in a future…

I’ve tried building asset bundles in the pre and post export cloud methods but my build times out if it takes too long. Is there a way around this?

I’d be interested in this too. What would the process be for using Pre-Post in cloud build for Asset Bundles?

@hypeNate definitely interested in this feature.

Currently we have a custom editor window for performing asset bundle builds. It would be nice to see this feature integrated into the IDE by default. Even if it’s just a basic select output directory and build currently active platform button.

A CLI would also be quite handy if we wanted to create our own AssetBundle CI build. But offloading this task to you guys would be well worth the money. Is Unity willing to host the bundles also for development purposes? Or perhaps will we be required to supply ftp details or similar?

Very excited to see what you guys come up with!

For the record, I’m also interested in building Asset Bundles manually, without Unity. It would open up the possibility of constructing custom AssetBundles by, say, a server, for game clients to stream.

Any news about this?
Also, a bit off topic but still related: any plans for being able to import FBX/OBJ (without them being in an AssetBundle) during runtime without the need of a third party plugin?

Hello I need to Build AssetBundles and include it in StreamingAssets folder to load HD/SD variant at runtime.

I only need to add a pre script build but I do not find how to do this. I know how to launch build and script before it with a menu entry. But UnityCloud build will not launch it.

Its been nearly 3 years since that original post. Is this something that may happen with Cloud builds anytime? I am also wondering if there are alternates to doing this outside the editor (like the command line options mentioned). Our app uses a lot of dynamic content that needs to be added this way to be downloaded in the app. Right now, the need for doing this using the editor makes the process cumbersome for us.

Hello @narayanb . I have found how to do and build AssetBundles in UCB and upload them to my server automatically. Really save my time.

How to do it? I am also seeking for soulution to build assetbundle automatically.

For instance I have an empty project with all my sprites (mercenaries and weapons). I assigned asset bundles and variants.

Create a main unity scene empty.
A prebuild script create AB like this:

// Build specific target
    static void Build(BuildTarget target, string path)
    {

        TestVersion();

      

        Debug.Log("Build Asset Bundles");
        BuildPipeline.BuildAssetBundles(path,
                                        BuildAssetBundleOptions.None,
                                        target);

        CopyAssetBundlesToStreamingAsset();


      
    }

I have a preproc define to enable only right Build method like this:

#if UNITY_ANDROID
        [MenuItem("Resources/AssetsBundles/Build Asset Bundles/Android")]
        public static void BuildAssetBundles()
        {
            Build(BuildTarget.Android, "AssetBundles/Android");
        }
#endif

Then AB is deleted and copyied in StreamingAssets in my Main game project. In my other project that manage mercenaries and weapons I upload to server in post buid script.

Add post build editor script in UCB that create AB and upload to my server with UnityWebRequest (or HttpWebRequest because depends of your server sometimes one work or the other).

sample code to put to AmazonS3 (read the doc on Amazon if needed)

Debug.Log("send to amazons3");
                request = (HttpWebRequest)WebRequest.Create(amazonS3SignedUrl);
                request.Method = "PUT";
                //request.ServicePoint.Expect100Continue = false;
                request.ProtocolVersion = HttpVersion.Version10;
                request.ReadWriteTimeout = 500000;
                request.Timeout = 500000;

                string filePath = "AssetBundles/"+plateforme+"/" + Pair.Key;
                using (Stream dataStream = request.GetRequestStream())
                {
                  
                    // envoie en streaming
                    byte[] buffer = new byte[8000];
                    using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
                    {
                        int bytesRead = 0;
                        long totalRead = 0;

                        while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            dataStream.Write(buffer, 0, bytesRead);

#if !UNITY_CLOUD_BUILD
                            totalRead += bytesRead;
                            EditorUtility.DisplayProgressBar("Uploading Asset Bundles", "Reading Asset " + Pair.Key, (float)totalRead / (float)fileStream.Length);
#endif
                        }
                    }


                }

#if !UNITY_CLOUD_BUILD

                EditorUtility.DisplayProgressBar("Uploading Asset Bundles", "Uploading Asset " + Pair.Key, progress / nbBundles);
#endif
                httpResponse = request.GetResponse() as HttpWebResponse;

                Debug.Log(httpResponse.ToString());
                httpResponse.Close();

Maybe you need certificate callback for https:

public static bool MyRemoteCertificateValidationCallback(System.Object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
    {
        bool isOk = true;
        // If there are errors in the certificate chain, look at each error to determine the cause.
        if (sslPolicyErrors != SslPolicyErrors.None)
        {
            for (int i = 0; i < chain.ChainStatus.Length; i++)
            {
                if (chain.ChainStatus[i].Status != X509ChainStatusFlags.RevocationStatusUnknown)
                {
                    chain.ChainPolicy.RevocationFlag = X509RevocationFlag.EntireChain;
                    chain.ChainPolicy.RevocationMode = X509RevocationMode.Online;
                    chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(0, 1, 0);
                    chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
                    bool chainIsValid = chain.Build((X509Certificate2)certificate);
                    if (!chainIsValid)
                    {
                        isOk = false;
                    }
                }
            }
        }
        return isOk;
    }







//set callback for HTTPS
        ServicePointManager.ServerCertificateValidationCallback = MyRemoteCertificateValidationCallback;

This is a good starting point. You need to have a server URL where to sent AB. Before PUT I POST on a server to obtain a signed Amazon URL.

Hope you will manage to create a great pipeline for AB and UCB. This saved my life and hours of build.

3 Likes