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
2
Question by Robert 1 · Jun 04, 2010 at 03:14 PM · webplayerloadresourcescsv

How to load CSV files from webplayer

Yes, I realize that I could simply make the extension of my CSV file .TXT and use TextAsset to load it, however I do not want to do this. The CSV extension must remain as-is.

Basically I have a CSV file that I need to load and get the full text from. I can't use TextAsset because it's not a TXT file, and I've tried using Resources.Load(), however I'm not sure what type to cast it to.

How can I load a CSV file and access its contents? I tried using System.IO.StreamReader, and while this works in the editor, it does not work in the web player.

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 Cyclops · Jun 05, 2010 at 05:54 PM 3
Share

Let me ask the obvious question, which I should have asked before :) Where is the file located?

avatar image Cyclops · Jun 05, 2010 at 06:07 PM 1
Share

And a second question - why do you want to keep the .csv extension? Is there a specific need, say another program reads/writes it? Depending on the reason, there may also be a solution or work-around for that.

3 Replies

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

Answer by Cyclops · Jun 04, 2010 at 04:04 PM

To quote from: Best way to output data from Unity: "...not available in the webplayer for security reasons." The extension doesn't matter, the Browser simply isn't allowed to read or write to the local machine. You could either make your program a stand-alone executable, or put the datafile on the Server.

Update: to demonstrate this is an issue with the web-player, try building a standalone executable. Your System.IO.StreamReader code should read the file with no problem (assuming no bugs). Does that solve your problem?

If your answer is "no, I want the Browser to read the file", then sorry, it won't work.

Depending on the type of data, you might be able to use PlayerPrefs. Also see Does Unity have cookies? Since you appear to want a .csv file, probably not, but I thought I'd mention them.

Comment
Add comment · Show 9 · 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 Tetrad · Jun 04, 2010 at 04:39 PM 0
Share

The question isn't about saving files, it's about loading them.

avatar image qJake · Jun 04, 2010 at 08:52 PM 1
Share

It doesn't matter if it's about saving or loading, the web player cannot read or write to the disk at all, for security purposes. This isn't possible, and he'd have to make the game a standalone EX$$anonymous$$

avatar image Tetrad · Jun 05, 2010 at 04:52 PM 0
Share

I know a little more background about this question than what's in the question. Basically the question should be "Can you use Resources.Load to load a file as a text asset that doesn't have the .txt extension". It's not about loading a file outside the unity bundle.

avatar image Cyclops · Jun 05, 2010 at 05:42 PM 0
Share

But is it about loading a file from the webplayer? Because that's what is in the title :) A standalone executable can read any type of file using .Net System.IO. A Browser can not read anything from the user's hard drive, regardless of file type.

avatar image Tetrad · Jun 05, 2010 at 05:53 PM 0
Share

This particular use case doesn't involve loading a file off the user's machine. The web player/streamreader stuff is a red herring that was intended to say "hey I tried doing it this way and found out it obviously doesn't work on the web player".

Show more comments
avatar image
0

Answer by dineshrajpurohit · Jun 20, 2012 at 03:22 AM

Unity Web player does not allow file manipulation(read or write). The best way to do this is using WWW in Unity to retrieve information from the file via PHP. Since CSV basically contains comma separated valued text, they can be passed echoed out as it is and on the unity side they can be split in an array using ',' (comma) delimiter. Let me know if you need more information or a sample code.

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

Answer by Zogg · Jul 02, 2013 at 02:51 PM

I think the answers miss the point.

You can actually "load" a .txt file from the webplayer when you refer to it from a TextAsset or put the file into a Resources folder. That's possible because in this case it's not actually loaded in runtime from the hard drive, but included in the executable - just like textures, sounds or whatever other resources you use in your program.

The asker wants to know (and so do I) if there is a way to do a similar thing with a .csv file, without changing the extension. It seems not to be possible, but maybe I'm wrong?

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

2 People are following this question.

avatar image avatar image

Related Questions

How do I make sure a resource is loaded or is instantiated? 2 Answers

Accessing 4.6 GUI build-in sprites in C# 0 Answers

load file with www on webplayer 1 Answer

WbPlayer Loading From File 0 Answers

Resources.Load("sprite") returning nil 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