• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by amirblum_nogame · May 20, 2017 at 09:21 AM · assetbundleassetbundlesbuildpipelineasset bundles

Exception when building asset bundle with variant using build map

Hi, I'm trying to generate AssetBundles using a build map (array of AssetBundleBuild objects) sent to BuildPipeline.BuildAssetBundles, as is shown in the second example in the documentation.

The issue appears when I try to create an asset bundle with a variant, which isn't shown in the documentation (or anywhere online). Assigning non-null-or-empty string to AssetBundleBuild.assetBundleVariant, I get a slew of identical errors in the inspector stating the "Variant folder path cannot be empty."

The code I am using is:

  var builds = new AssetBundleBuild[2];
 
  builds[0] = new AssetBundleBuild
  {
      assetBundleName = mainBundleName,
      assetBundleVariant = "variant1",
      assetNames = new[] { "Assets/troops/troop/variant1/troop.prefab" }
  };
 
  builds[1] = new AssetBundleBuild
  {
      assetBundleName = mainBundleName,
      assetBundleVariant = "variant2",
      assetNames = new[] { "Assets/troops/troop/variant2/troop.prefab" }
  };
 
  BuildPipeline.BuildAssetBundles(ASSET_BUNDLE_OUTPUT_PATH, builds, BuildAssetBundleOptions.None,
                                             EditorUserBuildSettings.activeBuildTarget);

Based on the workaround in this similar issue, I have tried putting the asset I am trying to turn into a bundle into various folder structures with the name of the bundle/variant/etc. all to no avail.

It is worth noting that when assigning the same bundle name and variant to this asset in the inspector and running BuildAssetBundles without a build map it runs fine, but I am trying to create an automated process...

Any help would be greatly appreciated. Thanks!

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image dirty-rectangle · Aug 30, 2017 at 02:20 PM 0
Share

We are seeing the same slew of errors in the same use context with BuildPipeline.BuildAssetBundles with Unity 2017.1.0p4. It doesn't cause any noticable runtime issues but it does generate very large build logs and is probably slowing down the build.

avatar image OriginalSINe · Sep 24, 2017 at 11:50 PM 0
Share

I am having this problem as well, in the newest version of Unity 2017.1.1. There are no empty strings in the file paths or build paths. This has been happening since I started using Unity in 5.5.

avatar image OriginalSINe · Nov 15, 2017 at 07:33 AM 0
Share

EDIT: Upon learning a bit more about the AssetBundle system, I've learned this merely changes the output file name. The file name is what I was trying to control with the variant (which was horrible idea).

I got back to working on my AssetBundle framework, and the thought occurred to me to simply not set assetBundleVariant, and just append it to the assetBundleName.

So ins$$anonymous$$d of

 AssetBundleBuild bundleBuild = new AssetBundleBuild
 {
      assetBundleName = "name";
      assetBundleVariant = "variant";
 }

You would have

 AssetBundleBuild bundleBuild = new AssetBundleBuild
 {
      assetBundleName = "name.variant";
 }

It's a hack, but it seems to be working for me so far.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How to import the object from server to unity 2 Answers

Loading a specific set of sprites with addressables 0 Answers

How to build only specified assets into assetbundle in unity 0 Answers

Loading Sprites from AssetBundle produces disfigured images. 0 Answers

Addessable asset download once 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges