- Home /
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.:)
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?
Answer by Jaap Kreijkamp · Sep 28, 2010 at 02:07 AM
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
Your answer
Follow this Question
Related Questions
Public variable in script different for every game object. 1 Answer
Saving variables? 3 Answers
Prefab (Project Folder) to a GameObject (on the Scene) 2 Answers
how to create boolean Varibles ? 3 Answers
Getting variable from another script 2 Answers