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 dot · May 16, 2010 at 03:53 PM · saveloadreadoutput.txt

creating txt file

is it possible? to create a file. Like saving some information for the future use of the game, so later the txt file can be loaded and the information used? how would one do that? what classes/functions could be used to do that? thanks

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Mike 3 · May 16, 2010 at 04:39 PM

you'll want to be using something along the lines of this: http://msdn.microsoft.com/en-us/library/system.io.file_members.aspx

WriteAllText is a good bet for writing to a file, takes a file path and a string to put in it

Comment
Add comment · Show 5 · 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 dot · May 16, 2010 at 06:18 PM 0
Share

ow. I must admit I'm not a good programmer at all. Seems weird when I'm looking at the page you pointed me to. Don't unity have some functions that could help people with the above problem? (I acknowledge that I might even ask the wrong question, but you probably know what I'm trying to learn here).

avatar image Eric5h5 · May 16, 2010 at 06:56 PM 0
Share

@dot: Those are the functions that Unity uses. Unity program$$anonymous$$g is based on $$anonymous$$ono/.NET.

avatar image Mike 3 · May 16, 2010 at 07:38 PM 0
Share

Theres not a lot to it... System.IO.File.WriteAllText("C:\test.txt", "abc"); ... will put abc into a file called test.txt for example

avatar image dot · May 18, 2010 at 11:32 AM 0
Share

Same to you. Thanks $$anonymous$$ike!

avatar image grimmy · Oct 05, 2011 at 08:52 AM 0
Share

I get an error when using this: 'WriteAllText' is not a member of 'System.IO.File'.

?

avatar image
1

Answer by Eric5h5 · May 16, 2010 at 05:40 PM

If all you want to do is save the game state, using PlayerPrefs is simpler than messing with files.

Comment
Add comment · Show 3 · 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 dot · May 16, 2010 at 06:15 PM 0
Share

no. actually I want to save a lot more than just, what I imagine, hides behind the term of "game state". I need to save strings of text or numbers, which could be read later.

avatar image Eric5h5 · May 16, 2010 at 06:58 PM 0
Share

@dot: PlayerPrefs can save strings of text or numbers with no problems, and read them later. Do you want the files to be read outside Unity? In that case PlayerPrefs wouldn't be appropriate.

avatar image dot · May 18, 2010 at 11:31 AM 0
Share

I guess both answers do it then. Thanks Eric. I'll let you know once I build something that you helped me with. Peace

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

1 Person is following this question.

avatar image

Related Questions

How to script a Save/Load option on IPhone? 1 Answer

Saving Game Problem 1 Answer

PlayerPrefsX - Not Saving? 1 Answer

Best way to save procedural world/mesh? 0 Answers

Save and load data with Javascript... 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