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 masabusharif · Oct 04, 2012 at 09:13 AM · c#javascriptiosassetbundle

Automatically load asset bundles on start from cache

Uploaded an assetBundle to a server, in my scene i have a download button that downloads the asset and caches (saves) them in the iphone documents folder, and instantiates the required object using:

 var request = assetBundle.LoadAsync("Sphere", typeof(GameObject));
 
 Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);

upon closing the app and reopening it i want the downloaded asset to load automatically on start, i have a script that checks if the file exists it instantiates it according to the following code

 IEnumerator Start () {
          print ("START FIRST");
         
     
          strPath = GetiPhoneDocumentsPath ();
         
          cachedAssetBundle = strPath + "/savedassetbundle.assetbundle";
         
         Debug.Log(cachedAssetBundle);
         
         if(File.Exists(cachedAssetBundle)) 
         {
             started=true;
         
         download = new WWW(cachedAssetBundle);
         yield return download;
             
             AssetBundle assetBundle = download.assetBundle;
             
 
         AssetBundleRequest request = assetBundle.LoadAsync("Sphere", typeof(GameObject));
         yield return request;
         
         Instantiate(request.asset, new Vector3(0f, 0f, 0f), Quaternion.identity);
         
         download.assetBundle.Unload(true);
         }
     }

Notes: 1) i am testing on an iPhone

2) the check for if an asset bundle exists works, as i have a game object that rotates when i close and reopen the app after downloading if started = true;

The problem is when i close and reopen the application the asset bundle doesnt load automatically on start, even though the asset bundle exists

Comment
Add comment · Show 6
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 masabusharif · Oct 04, 2012 at 11:42 AM 0
Share

format code edited

avatar image sebas77 · Oct 04, 2012 at 12:26 PM 0
Share

how do you deter$$anonymous$$e that it is not loaded? If it is just because it is not shown on the screen, I suspect the problem could be due to the Unload(true)

avatar image masabusharif · Oct 04, 2012 at 12:40 PM 0
Share

i deter$$anonymous$$ed that its not loaded because it's not shown on the screen i commented the line containing Unload(true), still it didn't show up All i want to do is display the object on screen on start

avatar image masabusharif · Oct 04, 2012 at 02:25 PM 0
Share

i get the following errors

You are trying to load data from a www stream which had the following error when downloading. malformed UnityEngine.WWW:get_assetBundle() c__Iterator1:$$anonymous$$oveNext() (at Assets/Example Project/Plugins/Show.cs:72)

avatar image sebas77 · Oct 04, 2012 at 02:31 PM 0
Share

all right, then it "could" be that you did not build the assetbundle for iOS. The BuildPipeline.BuildAssetBundle has a targetPlatform parameter and it must be set to iPhone

Show more comments

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.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Audio: how do I immediately play a new audioclip without delay(code included)? 2 Answers

GetComponent Help. 1 Answer

How to access Vuforia C# library from Javascript 2 Answers

C# try catch block doesn't work for iOS? 2 Answers

Multiplayer Problems 1 Answer


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