x


How to save a gameObjects on a prefab and variables with a script?

I'm trying to save all data of a game(like when you save a game) but for this game you need to save a gameobject to a prefab using a script to do it. And the other thing is to save data of the variables. if some one can help me please.:)

more ▼

asked Sep 27 '10 at 10:13 PM

user-4347 (google) gravatar image

user-4347 (google)
29 11 11 13

Could you be more clear about your question? Are you asking how to save a GameObject as a prefab, or how to save a game's progress while the user is playing the game?

Sep 28 '10 at 12:16 AM BinaryCaveman

yes, save a gameobject as a prefab

Sep 28 '10 at 02:44 AM user-4347 (google)
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

In the Unity runtime (so outside the editor) you can't dynamically generate new prefabs (you need UnityEditor classes for that). GameObjects and their script data are serialisable so you could serialise their state using a script that enumerates over all gameobjects in a scene. To help you started on serialising gameobjects take a look at:

http://www.unifycommunity.com/wiki/index.php?title=Save_and_Load_from_XML

more ▼

answered Sep 28 '10 at 02:07 AM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

(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:

x5080
x2087
x823
x437
x343

asked: Sep 27 '10 at 10:13 PM

Seen: 1957 times

Last Updated: Sep 27 '10 at 10:13 PM