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 JasonB · Dec 10, 2012 at 06:12 PM · assetdatafilesinternal

How can I get the data from text files located inside my assets?

Here's my situation.

I would like to have text files located inside my assets. These are basically Notepad-editable "map" files.

How can I reference them so that I can take the data from the files and copy them elsewhere onto the user's system?

The end result I'm after is that the game has the capability of reading map files from a Maps folder located on the user's system. I want in-built maps to be "copied" to that folder on start up (to keep them intact/up to date) while still allowing people to put their own custom maps inside the same folder.

So in other words, I can't figure out how to make reference to my internal .txt files and retrieve the string data from them. All the rest I know how to do. All I can seem to find about this are editor-related scripts, and I don't think those are what I need.

Comment
Add comment · Show 1
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 sparkzbarca · Dec 10, 2012 at 06:48 PM 1
Share

search for saving at runtime. There isn't really a standard way. I THIN$$anonymous$$ it has to do with the security and with there not being a standard safe directory you could always be sure you could access and save to across operating systems.

search for saving at runtime nad check out

http://www.$$anonymous$$dthecube.com/blog/2009/11/reading-text-data-into-a-unity-game

1 Reply

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

Answer by yoyo · Dec 11, 2012 at 06:35 AM

If you store your files with a .txt extension then Unity will treat each file as a TextAsset, and you can uses Resources.Load to load them and textAsset.text to access them.

Alternatively, since you are creating a standalone build (I presume?) you can use standard System.IO.File calls for file manipulation, and you can find your data relative to Application.dataPath.

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 JasonB · Dec 11, 2012 at 04:01 PM 0
Share

Thanks, I appreciate it. Resources.Load was all that I needed to know.

avatar image yoyo · Dec 11, 2012 at 05:09 PM 0
Share

Glad to help. @sparkzbarca's link above looks pretty useful too.

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

Is it possible to reference a custom file type in the inspector? 1 Answer

Is there a way to extract assets from Unity MMO files? 1 Answer

Build settings: how to export files into the build 1 Answer

Create / preserve file in asset folder. 2 Answers

Are all ScriptableObject assets included in the build? 4 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