Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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
1
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 this 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 this 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 - This 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
Add comment
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
0

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 everything 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.

This can actually be quite onerous and that is why many games have "save zones" which happens between levels or in a sleep/wake up fashion so that you wont need to put everything back in exactly the same state as you found it.

Secondly, if its something 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 things to files. You can use the System.IO calls for this (read up on StreamWriter and File.OpenText).

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

Comment
Add comment · 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.

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

Load, Save and Options Gui Help 1 Answer

Sharing Violation On Path 1 Answer

Saving boolean values using PlayerPrefs 1 Answer

Serialized data not getting saved in iPhone 1 Answer

Implement save and load option in a game 2 Answers


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