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 gilgada · Feb 26, 2013 at 07:31 PM · textexportfilewebaccess

Where to put my text files when exporting a project

I have a unity application I've just exported. The application does a lot of reading from text files found in ~/assets/data but these don't seem to be part of the .unity3d file that exports. Where should I stick these files in order for the web version of the application to access them?

Comment
Add comment · Show 3
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 robertbu · Feb 26, 2013 at 07:45 PM 0
Share

They should remain in the project if you put them in Assets/Resources. But I'm surprised they are not available. Are you accessing them through file i/o or are you using the TextAsset class?

avatar image gilgada · Feb 26, 2013 at 10:51 PM 0
Share

I use 'System.IO' $$anonymous$$y filepath takes a searchfield term and composes the directory path: filepath = "./assets/data/" + searchfield.Search + ".txt";

avatar image robertbu · Feb 26, 2013 at 11:21 PM 0
Share

I doubt this will work for any form of compiled build. You have a few choices. You can convert your 'System.IO' code to use the TextAsset class. If the files aren't huge, you can statically link them in, or you can place them in the Resources folder and do a Resources.Load() to pull them as you need them.

Or you place them outside your project. On web builds, there are restrictions on what files you can access. I don't know if you can use 'System.IO', but I believe you can use the WWW class for files that live on your server.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by unormal · Feb 27, 2013 at 12:44 AM

It is easiest to load text assets this way:

TextAsset Asset = Resources.Load("Data/Blueprints") as TextAsset;

Asset.text then contains the file data.

Note that you should not use the extension (in this case the actual file is Blueprints.xml). You must also use only .txt and .xml extensions, otherwise unity will not include them in the file.

...or .html, .htm or .bytes as pointed out by Eric5h5.

Comment
Add comment · Show 2 · 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 Eric5h5 · Feb 27, 2013 at 12:49 AM 0
Share

That's not really the easiest way. The easiest way is just to make a public variable, then drag'n'drop. That's also less brittle, since you can rename/move assets to your heart's content without breaking anything, while avoiding the usage of strings, plus it allows Unity to only include assets in a build that you're actually using.

avatar image unormal · Feb 27, 2013 at 12:51 AM 0
Share

Yeah, that's true if you're working with data inside of game objects. I was presu$$anonymous$$g he was using 'pure' code management objects/singletons, which is how I tend to work with large textual asset data. However, if you're working with game objects, you're certainly right.

avatar image
0

Answer by unormal · Feb 27, 2013 at 12:45 AM

Make sure the extension is either .txt or .xml, and that they are in the resources folder. Unity won't drag along text files that aren't named .txt or .xml.

Comment
Add comment · Show 2 · 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 Eric5h5 · Feb 27, 2013 at 12:47 AM 0
Share

Or .htm, or .html, or .bytes.

avatar image gilgada · Mar 15, 2013 at 02:55 PM 0
Share

yeah they are saved as txt files, they still dont carry over

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

11 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

Related Questions

Load and save text from web server 2 Answers

Parse an online text file 1 Answer

Cannot edit text file. 0 Answers

Iphone: How to read a file created by another application ? 1 Answer

Loading TextAsset returns null 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