x


iOS and Android reading/writing files

Hi!

I'm attending to create a level editor that'll work both on iOS/Android devices as on desktops. The goal is to save objects types and rotations on one dimensional level, so it should like:

1 object2 60
2 object4 30
3 object6 30
4 object2 90
5 object6 30
6 object3 330
7 object7 270
8 object2 120
9 object21 30
10 object3 0

...where the first variable will be position in meters from the beggining, second one, the object type, and the last one - Y rotation of an object. I need some other variables in those .ini(? or other?) like level lenght in meters, best scores etc.

So, my question is - how to do it? How to save a file like that on android, iOS and desktop - to create levels?

And, the next question is - how to read them to get the right variables?

Thanks!

more ▼

asked Mar 23 '12 at 03:52 PM

neurode gravatar image

neurode
0 1 1 1

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

.NET handles file i/o with the System.IO namespace. You can probably find some forum/web posts that relate specifically to Unity, like this one. You'll have to deal with a number of issues, depending on which platforms you want to target.

If you need help figuring out which folder you should be accessing, Unity will generally provide a safe location via Application.persistentDataPath.

There are many ways to accomplish these tasks. If you're just getting started, you'll probably have a somewhat easier time using helper functions like File.ReadAllLines() and File.WriteAllLines(), so that you can read or write file contents line-by-line with a StringReader or StringWriter.

more ▼

answered Mar 23 '12 at 07:05 PM

rutter gravatar image

rutter
5.2k 2 11

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2489
x1968
x93
x10
x8

asked: Mar 23 '12 at 03:52 PM

Seen: 2760 times

Last Updated: Mar 23 '12 at 07:05 PM