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 ignotuscaligo · Jun 10, 2013 at 10:59 PM · wwwruntimefilestreamingassets

Using WWW to load all files in StreamingAssets directory

Is it possible to use WWW to load any and all files in a given directory within StreamingAssets, or do I have to know the explicit name of every file I'm looking to load?

For examaple, "StreamingAssets/" contains a list of .xml files of arbitrary file names "dataSet01.xml", "saveFile-3.xml", "character_data_set_17.xml", so on, and I need to load them all at runtime.

Comment
Add comment
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

2 Replies

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

Answer by Julien-Lynge · Jun 10, 2013 at 11:47 PM

This isn't really a WWW question. There isn't any way to download all files from a directory regardless of the technology. What you need is some way to get a directory listing.

Where is StreamingAssets located? Are you trying to load from the local disk or from a folder in a web directory? If from local disk, look for ways to get directory listings with C# (it's not Unity-specific). If it's remote, you have to make the directory accessible, and that has to be done in Apache or whatever you're running (and it's different for HTTP vs FTP).

Comment
Add comment · Show 3 · 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 ignotuscaligo · Jun 11, 2013 at 12:54 AM 0
Share

The directory listing seems to be my answer here. I'll set up a known file with a listing of all the other files to load.

I'm using the builtin "Strea$$anonymous$$gAssets" directory provided by Unity due to the fact that it gives me a multi-platform location where I can store and replace files outside of the editor. The main use of WWW is due to the fact that the directory is compressed on Android and i believe iOS, so I can't use .net's IO classes to access the files.

Thanks for the response!

avatar image ben06feb ignotuscaligo · Aug 29, 2016 at 07:37 AM 0
Share

Did you got any solution, me too need to implement this one of my game which made in WebGL, I couldn't access Strea$$anonymous$$gAssets when uploading the file in L$$anonymous$$S Server. Including WWW class also not giving the expected result.

avatar image ben06feb ben06feb · Aug 30, 2016 at 05:32 AM 0
Share

Hi,

Access Strea$$anonymous$$gAssets path folder using WWW class

  public string filePath = Application.strea$$anonymous$$gAssetsPath + "/UserDetails.xml";
         public string result = "";
   
   void Awake () 
   { 
   filePath = Application.strea$$anonymous$$gAssetsPath + "/UserDetails.xml"; 
   }
   
   void Start () 
   { 
   StartCoroutine(userDetailsXmlPath() );
   }
   
         IEnumerator userDetailsXmlPath() 
         {
             print (filePath);
     
             if (filePath.Contains ("://") || filePath.Contains (":///")) {
                 WWW www = new WWW (filePath);
                 yield return www;
                 result = www.text;
     
                 print (result);
                 FetchUserDetails ();
             } else {
                 result = File.ReadAllText (filePath);
     
                 print (result);
                 FetchUserDetails ();
             }
         }
     
         public void FetchUserDetails()
         {
             XmlDocument userXml1 = new XmlDocument ();
     
             userXml1.LoadXml(result);
     
     
             XmlNodeList userList = userXml1.GetElementsByTagName ("user");
     
             foreach(XmlNode userValue in userList)
             {
                 XmlNodeList userContent = userValue.ChildNodes;
                 objUser = new Dictionary<string, string>();
     
                 foreach(XmlNode value in userContent)
                 {
                     objUser.Add (value.Name, value.InnerText);
                 }
     
                 userFullDetails.Add (objUser);
     
                 userCountInXml = userList.Count;
     
                 userId = new string[userList.Count];
                 questionSetOfUser = new string[userList.Count];
             }
     
             AssignUserXmlValuesToArray ();
         }
avatar image
0

Answer by Pallav-Nawani · Jun 23, 2018 at 06:10 AM

Alternatively, you could create a file called 'filelist.txt', which lists all the files you need to load. Then, first download filelist.txt, parse it, then download one by one all the files.

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

17 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to load an image at runtime via WWW correctly 1 Answer

Localy load XML data from StreamingAssets folder 0 Answers

[help]How can I read the file in StreamingAssets on iPad/iPhone platform??? 0 Answers

How to read xml file on Android using www and StreamingAssets? 2 Answers

Loading and playing AudioClip at runtime 2 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