Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by mvm95 · Mar 26, 2017 at 05:16 PM · webglsystem.iowww class

How can I access an external folder in the WebGL build of my app?

In my standalone app, I get the names of files in a folder that is located in the same place as the executable using Directory.GetFiles(). How can the same thing be achieved in a WebGL build if I put the folder in the same place as the index.html?

I've tried using the WWW class, but I think it can only retrieve information about individual files, not folders. I need to get information about the folder, since I don't know what the names of the files or quantity of files will be. Basically, I want to be able to iterate through the contents of the folder, using the filenames and later loading the files. WebGL is pretty challenging to debug, but the WWW object seems to be null when given the url of a folder since in Debug.Log all of the properties of the object print out as blank:

 WWW www = new WWW(Application.dataPath + "/myDir");
 yield return www;

I've also tried using mapPath() the way it is used in an answer I found to a similar question: Answer regarding mapPath

It is supposed to map the virtual path to a physical directory that can be passed in to Directory.GetFiles(), but that is throwing a null reference error.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by mvm95 · Apr 02, 2017 at 09:55 AM

Well, the only solution I've found is in the comments on the only answer to a similar question: Less than ideal solution

Basically, since the WWW class can get individual files, the workaround was to create a text file that contains the names of all the files in the directory. Any time a user adds a file to the directory, they will also have to update the text file, and then the information loaded from the text file (each file name) can be used to get each file in the directory. I hope somebody finds a better way, so users don't have to remember to update the text file, which could result in typos that end up excluding 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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to stream a image or text in webGL? 0 Answers

Is there a way to load images into a WebGL app? 2 Answers

WWW class on WebGL: URL is wrong 1 Answer

Load image from url in Webplayer 1 Answer

File Paths to load files with WWW for WebGL 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