• 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
Question by Mike Ledwards · Feb 05, 2011 at 03:43 PM · gamesaveloaddata

What are the basics of saving and loading game?

I know that saving a game is dependant on the game and it's content so there is no simple answer t this, but i can't seem to find a good explaination of how to do it...

i believe there are two ways to go about it, XML and Player Prefs or something? Can some1 please give me an explaination of either?

e.g

function SaveGame(){

what do i type here?So (HERE) i can enter the save game destination?;

& What do i say so that (this) is the data i save?;

}

Comment

People who like this

0 Show 1
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 Simple · Feb 08, 2011 at 01:15 PM 0
Share

http://answers.unity3d.com/questions/971/how-to-scrip-a-save-load-game-option

Here is enough stuff for starting. Also there is a lot about exporting arrays to XML in Adobe ActionScript 3 reference. You can write a few scripts in Flex Builder(As I was doing at first time, because I started FlexBuilder much earlier than Unity). There is a free version of FB by the way.

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by Simple · Feb 05, 2011 at 04:32 PM

Basics are:

Saving

1.Decide what exact information u want to save

2.Make a script that gathers this information in data array

3.Make save menu(and pause game)

4.Save this data array as txt file(for starting) on "Save button pressed". Better use binary files.

5.Return to game.

Loading

Make loading menu and loading screen.

  1. Let player choose which file to load
  2. Open your save file for input.
  3. Make a script that inputs data from your file to data array. Then it accepts specific data to specific
    objects on your scene. Of course you need to instantiate mostly all scene with all objects with properties from data array.
  4. Start game on loaded scene.

It is rather big code and it depends on what you want to save. You can read about import/export and files in reference documentation.

Comment
Mai hime
GameGuy
Mike Ledwards
SrBilyon
sarahAiyad

People who like this

5 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 Mike Ledwards · Feb 08, 2011 at 11:58 AM 0
Share

good answer, thanx for the response. i understand what i want to save... things like players name, level, stats and inv items but what i need to know is how to script the filepath for a savefile. I have traulled through the documents for the past week and can't find what i'm lookin for.

avatar image chelnok · Aug 20, 2012 at 12:51 PM 0
Share

Application.dataPath Contains the path to the game data folder. More info: http://docs.unity3d.com/Documentation/ScriptReference/Application-dataPath.html

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

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

1 Person is following this question.

avatar image

Related Questions

How to save data with the webplayer avaiable to all users? 1 Answer

Saving and Loading and assinging to gameobject 0 Answers

How to make a save and load option 2 Answers

Problem Saving game progress 1 Answer

Save and Load a Game 1 Answer


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