• Unity
  • Services
  • Made with Unity
  • Learn
  • 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
  • Forums
  • Answers
  • Feedback
  • Issue Tracker
  • Blog
  • Evangelists
  • User Groups

Navigation

  • Home
  • Unity
  • Industries
  • Made with Unity
  • Learn
  • Community
    • Forums
    • Answers
    • Feedback
    • Issue Tracker
    • Blog
    • Evangelists
    • User Groups
  • Get Unity
  • Asset Store

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 /
  • Help Room /
avatar image
0
Question by StanGabes · Dec 28, 2016 at 11:21 AM · c#coordinatessave datasave-to-filesave game

How do I save coordinates to a text file?

I'm in the making of a simple tower 2D defense game, for this I need to make waypoints for the enemies to follow. I already made it so I can save my maps (different gras types) to a text file, but how do I save different coordinates to a save file while keeping the order?

My maps are based on a grid, so I need to store coordinates like 3,4-6,7-8,9.

How do I store/read them the best way?

PS I do it in C#

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
Best Answer

Answer by RobAnthem · Dec 28, 2016 at 11:23 AM

Using simply a binary formatter. You can read up on it here Binary Formatting

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 StanGabes · Dec 28, 2016 at 11:30 AM 0
Share

Thanks I think that's going to work, but how is the file going to look, because I would like to make them manually. I think it's going to be unreadable for humans. Do you have any suggestions?

avatar image Owen-Reynolds StanGabes · Dec 28, 2016 at 05:48 PM 0
Share

Then don't use a binary formatter. Just Search and read about how to read/write a normal text file in Unity.

avatar image
1

Answer by UnityCoach · Dec 28, 2016 at 07:11 PM

You can use XML, here's how to do it or make your own parser, using System.IO

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

10 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

Related Questions

Error writting a file 1 Answer

Save Blendshape values 0 Answers

How To Save and Load player position using Serialization? 0 Answers

Can someone tell me what is wrong with this script? 1 Answer

Saving Game Data to iOS Device 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges