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
1
Question by NPtech · Jan 21, 2017 at 06:48 AM · webglreadwww classrewriting

How to read and rewrite text files on a local host with WebGL?

Hi guys,

I'm making a game where the levels are generated by several parameters, which are saved on an external text file. The user's choices in the game are saved as numbers on a second text file.

I'm using C#, and call these files with (for example):

     string fileName1 =
     Application.dataPath + @"\TempVars.txt";

     string fileData = System.IO.File.ReadAllText(fileName1);

And it works perfectly on a PC build. But, I need this game on the web, and that's where I'm stuck. I understood that I need to use the WWW class in order to call these file on a host, but I can't figure out how to use it. (I'm trying it on a local host, and I can't seem to turn the www class to a string or to reverse the process)

Can someone please explain to me how exactly to READ and REWRITE text files, that are on the local host with the webplayer? Or at least refer for a good guide on how to it.

Thanks!

Comment
Add comment · Show 2
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 jodyruben · Mar 20, 2017 at 08:21 AM 0
Share

got the same problem.

maybe this one can help http://stackoverflow.com/questions/34116366/editorutility-openfilepanel-for-unity-webgl-runtime

avatar image RobAnthem · Mar 20, 2017 at 08:31 AM 0
Share

It is bad practice to use text files for such a thing, because you have to parse the data back in. It is better to use proper serialization methods. I know this doesn't answer your question, but I believe even webplayer uses Application.persistentDataPath. Don't quote me on that though. Still, you have to use the WWW which is essentially like the web version of System.IO.

Also, if you want a quick way, PlayerPrefs works too.

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

7 People are following this question.

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

Related Questions

File Paths to load files with WWW for WebGL 0 Answers

Is there a way to load resources with unkown case (.png/.PNG) using www objects? 1 Answer

Why WWW class is not working with WebGL 2 Answers

How can I get a string to work as the key to a dictionary filled with the text of a www object? 0 Answers

How can I access an external folder in the WebGL build of my app? 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