Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
0
Question by MarimoAli · Mar 19, 2015 at 06:26 PM · unity 5assetbundlecrossplatformloading during runtime

Multi-resolution assets using Unity5.0 Assetbundles

Hello,

following this discussion on the Unity forums, I decided to dig around and see how the new assetbundles works. I found a video from Unite2014 about it where they did exactly what was described in that thread about having different assets for different builds. Luckily the person who held the presentation also uploaded the source that he used to demo the new Assetbundle features.

Using the project as a template I was able to create a SD and HD version of a sample sprite. However when Implementing the code to my own project I wasn't able to do so. The scripts I used are the same as in the assetbundle demo mentioned above. Bellow I have screenshots of my folders and assetbunde labels:

alt text

As the folder names suggest, they have the label suffix of .hd, sd and ud respectively.

alt text

Shows the labels.

The scene used in this is an empty scene with a canvas and a panel, the panel uses the BG sprite in its Image component.

Bellow is the loader script I'm using:

 public class LoadVariants : BaseLoader {
 
     public string variantSceneAssetBundle = "xplatform/assetbundletest.unity3d";
     public string variantSceneName = "assetbundletest";
     public string[] activeVariants = {"hd"};
 
     // Use this for initialization
     IEnumerator Start () {
 
         yield return StartCoroutine(Initialize() );
 
         // Set active variants.
         AssetBundleManager.Variants = activeVariants;
 
         // Load variant level which depends on variants.
         yield return StartCoroutine(LoadLevel (variantSceneAssetBundle, variantSceneName, true) );
         
         // Unload assetBundles.
         AssetBundleManager.UnloadAssetBundle(variantSceneAssetBundle);
     }
 }


Which is exactly the same as in the demo, but with the label strings changed. All the other bundle building code, loading code, etc is the same as in the demo.

Did I miss a vital piece of setup ?

Thanks in advance for your time!

screen-shot-2015-03-19-at-160112.png (7.1 kB)
screen-shot-2015-03-19-at-160238.png (8.1 kB)
Comment
Add comment · Show 14
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 Mike-Geig ♦♦ · Mar 19, 2015 at 03:11 PM 0
Share

Are you in simulation mode? Also, show us screenshots of where you apply the asset bundle labels. I just want to see exactly how you named them

avatar image MarimoAli · Mar 19, 2015 at 05:18 PM 0
Share

Hey $$anonymous$$ike,

I'm not using simulation, below is a screenshot of it. I have added a imgur gallery with the images you requested as I couldn't upload images to this answer for some reason.

Thanks for the quick respone :).

avatar image Mike-Geig ♦♦ · Mar 19, 2015 at 05:27 PM 0
Share

Your code is loading a scene, not your asset variants. Are you sure you want to call LoadLevel?

avatar image MarimoAli · Mar 19, 2015 at 05:35 PM 0
Share

Yes, I am loading a level. But I'm also specifying the asset variant to either sd,hd or ud. From what I underestood, it also loads the sprites assetsbundle, because of dependency. Here is an console log of what I mean.

avatar image Mike-Geig ♦♦ · Mar 19, 2015 at 05:41 PM 0
Share

I am assu$$anonymous$$g the SD items get loaded into your scene?

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
-3

Answer by VBercut · Jun 29, 2015 at 11:56 AM

Don't use it, it's bad

Comment
Add comment · Share
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
0

Answer by MarimoAli · Mar 19, 2015 at 10:53 PM

Alright Mike, as I have mentioned before, it works when using the demo provided by your colleague from Unite2014. He built the assetbundles the same way I did, in addition he has a couple more elements in the scene, where I have only a sprite.

Then he has a empty scene with a GameObject that has a this loaderscript in it:

 public class LoadVariants : BaseLoader {
 
     public string variantSceneAssetBundle = "variants/variant-scene.unity3d";
     public string variantSceneName = "variant-scene";
     public string[] activeVariants = {"hd"};
 
     // Use this for initialization
     IEnumerator Start () {
 
         yield return StartCoroutine(Initialize() );
 
         // Set active variants.
         AssetBundleManager.Variants = activeVariants;
 
         // Load variant level which depends on variants.
         yield return StartCoroutine(LoadLevel (variantSceneAssetBundle, variantSceneName, true) );
         
         // Unload assetBundles.
         AssetBundleManager.UnloadAssetBundle(variantSceneAssetBundle);
     }
 }
 

// Set active variants. AssetBundleManager.Variants = activeVariants;

Sets the variant I would like to use, and in my previous the RemapVariantName func find the closest name to it and uses(loads) it, since they are xplatform/ sprites .sd/ud and hd, they all share the same id and can be read from the manifest. If I understood the video correctly. Wasn't this essentially the biggest update of the 5.0 assetbundles?

When editing the assetbundles demo by adding the ud version sprites and rebuilding the assets, it works. By changing in the inspector to sd, hd or ud. It changes which assets are to be loaded. However when trying to do the exact same in my project it doesn't load them. Just to clarify, the demo came with SD and HD examples and I added a UD assets folder and rebuilt the assetsbundle, as can be seen here.

Comment
Add comment · Show 5 · Share
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 Mike-Geig ♦♦ · Mar 20, 2015 at 03:51 AM 0
Share

I just loaded up the demo project you were talking about and the variant loading on it doesn't appear to work correctly. Using the variant loader scene, if I load HD assets (which are already in that scene) it works fine. If I try to load the SD I get blank text and a cube without a texture (same problem you are having). It is possible that the api for asset bundles changed slightly since this demo was released. As it stands, it doesn't appear to work in the latest version of Unity 5.

avatar image MarimoAli · Mar 20, 2015 at 02:58 PM 0
Share

I'm not certain why it isnt working for you correctly, but the demo works very well for me. Are you in simulation mode/ have you built the assetbunles :D? I couldn't find any differences/changes in the API from the scripts in the demo.

Whats really confusing is the fact, that when printing logs, it shows that its loading the scene assent bundle and the dependency assetbundles, that have the sprite. I guess, Ill have to look more into assetbundles.

avatar image Mike-Geig ♦♦ · Mar 20, 2015 at 03:01 PM 0
Share

Right, it is loading the sprite asset bundle, but you have no code to actually put it in the scene (which is why it doesn't appear). The same thing is happening in the demo project. Unless I am missing something with the new system, just because assets are loaded doesn't mean they are actually used in a scene.

As for your other question: I have built the asset bundles with the demo and tested in both simulation and non modes.

avatar image swipeware · Mar 24, 2015 at 08:36 AM 0
Share

I was having an issue with the demo project not switching to sd even though I changed the 'Active Variants' setting in the Inspector of the VariantLoader scene. I got it to work properly by unchecking the menu option "AssetBundles->Simulate AssetBundles" (it's checked on by default). After unchecking that option I can enter 'hd' or 'sd' in the variant element to get it to load the hd/sd content.

avatar image Mike-Geig ♦♦ · Mar 24, 2015 at 03:14 PM 0
Share

Yes, it turns out I was using an older version of the project. The new one works fine in Unity 5 release. After viewing the user's project, my assumption is that there is a bug that needed to be reported.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Asset bundle too small after creating with Unity 5 0 Answers

Issue: CrossPlatformInput...Multiple Inputs not taken, 0 Answers

Load Animator Runtime. 0 Answers

how to split a mesh into multiple pieces 0 Answers

Assetbundle version - download only edited assetbundles 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