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
1
Question by dansav · Sep 06, 2012 at 10:16 PM · assetbundleloadtextasset

problems getting text string from assetbundle

I'm trying to get a text file from an assetbundle and put it in a string variable. I am successfully able to load the assetbundle and take a texture from the bundle and apply it to an object, but something is wrong with my code for grabbing a txt file hat1_info.txt and trying to put it into a TextAsset. I don't get any errors except the textasset is null.

 downloadAssetBundle();
 
 function downloadAssetBundle(){
 var urlEditor = "file:///Users/dan/Desktop/hat1bundle.unity3d";
 var hat:GameObject;
 var bundle:AssetBundle;
 // Start a download of the given URL
 if (Application.platform == RuntimePlatform.OSXEditor){
 var www:WWW = WWW.LoadFromCacheOrDownload (urlEditor, 1);
 yield www;
 bundle = www.assetBundle;
 makeitso(bundle);
 }
 }
       
 function makeitso(bundle:AssetBundle){
 Debug.Log("making it so");
         
 //this works      GameObject.Find("Sphere").renderer.material.mainTexture=bundle.Load("hat1_texture",Texture);   
 //this does not work gives back null
 var txt:TextAsset = bundle.Load("hat1_info", typeof(TextAsset)) as TextAsset;
 
 Debug.Log(txt); //gives back null
 Debug.Log(txt.text);
 var s=txt.text;
 Debug.Log(s);
 }
Comment
Add comment · Show 1
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 dansav · Sep 07, 2012 at 01:43 AM 0
Share

Follow up. I can load the file fine if I put it in the resources folder using Resources.Load. Also I have a gameObject in the assebundle that also loads fine. So A texture loads fine and a gameObject loads fine but it doesn't like that text file, but resources load can handle it.

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by dansav · Sep 07, 2012 at 01:56 AM

I found the problem.

The problem is even though I updated my assetbundle, the download function

WWW.LoadFromCacheOrDownload.

was loading an older cached version.

I found the answer by checking AssetBundle.Contains and finding out it was false. So I was not working with the assetbundle I thought I was working with.

Dan

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

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

7 People are following this question.

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

Related Questions

How to, tell apart, Instance or Instantiated GameObject vs Loaded GameObject. 0 Answers

Getting the assets inside a bundle from unity 5 vs Unity 4 0 Answers

Deserialize .XML file from AssetBundle? 0 Answers

I want to load object from my computer or google drive. 1 Answer

is that possible to load prefab from script. 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