• 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 UniqueProductionZ · Jan 13, 2014 at 07:29 PM · saveloadmenuloading

basic Saving and Loading

I am in the middle of creating a RPG Game and i am focusing on saving and loading. What i need is a script that saves my characters exact location or possibly and "Auto-Save" feature. I am hoping to create a save game button for my pause menu. The reason why i am asking t$$anonymous$$s is because i have searched all over Google and found many results however the results was not what i needed and did not help me at all. I also have no idea where to start for the creating of Saving and Loading feature. I am also wanting a loading button for my main menu so when the user clicks the button it loads their game save.

I am sorry if t$$anonymous$$s is irrating of asking the same question but i didn't understand the other scripts and tutorials because i got many errors with them.

Thanks in advanced

UniqueProductionZ

Extra - T$$anonymous$$s is my pause menu script (I am in the middle of creating my main menu scene now:

   private var pauseEnabled = false;    
   
   function Start()
     {
     pauseEnabled = false;
     Time.timeScale = 1;
     AudioListener.volume = 1;
     Screen.showCursor = false;
     }
  
     function Update()
     {
         //check if pause button (escape key) is pressed
         if(Input.GetKeyDown("escape"))
         {
            //check if game is already paused
            if(pauseEnabled == true)
            {
              //unpause the game
              pauseEnabled = false;
              Time.timeScale = 1;
              AudioListener.volume = 1;
              Screen.showCursor = false;
            }
  
            //else if game isn't paused, then pause it
          else if(pauseEnabled == false)
            {
              pauseEnabled = true;
              AudioListener.volume = 0;
              Time.timeScale = 0;
              Screen.showCursor = true;
            }
         }
     }//end Update function
     function OnGUI()
     {
  
         if(pauseEnabled == true)
         {
            if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2+25 ,250,50), "Option"))
            {
              Debug.Log("GUI.Button : Options : pressed");
            }
            if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2-25 ,250,50), "Resume"))
            {
              if(pauseEnabled == true)
              {
               //unpause the game
               pauseEnabled = false;
               Time.timeScale = 1;
               Screen.showCursor = false;
               AudioListener.volume = 1;
              }
            }
         }
 }//end OnGUI function    
Comment
BZS

People who like this

1 Show 0
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

1 Reply

· Add your reply
  • Sort: 
avatar image

Answer by Fabkins · Jan 13, 2014 at 10:32 PM

Firstly, you need to understand that you are going to have to save the state of everyt$$anonymous$$ng that is important to you in your game. Hence existence and state of every object in your game. Obviously you will then need to reverse the process.

T$$anonymous$$s can actually be quite onerous and that is why many games have "save zones" w$$anonymous$$ch happens between levels or in a sleep/wake up fas$$anonymous$$on so that you wont need to put everyt$$anonymous$$ng back in exactly the same state as you found it.

Secondly, if its somet$$anonymous$$ng like an RPG, I would NOT recommend using PlayerPref class. Thats a really simple way of storing value pairs. Not really suitable if you are trying to save big list of inventory and map information.

Consequently you will need to save t$$anonymous$$ngs to files. You can use the System.IO calls for t$$anonymous$$s (read up on StreamWriter and File.OpenText).

http://forum.unity3d.com/threads/5084-Can-I-read-and-write-text-files-using-Javascript

Comment

People who like this

0 Show 0 · 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

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

19 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Saving/Load using menu C# 1 Answer

Save works for computer but not once i create the build and load it on the android 1 Answer

Save & Load Game question 3 Answers

Saving and loading game with PlayerPrefs 1 Answer

in game menu for load, save, quit to main menu scene and volume. also a question on opening scenes 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