Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
5
Question by Derpybunneh · May 19, 2016 at 03:48 PM · c#savesaving

Save and load whole scene

Hello! I don't know why this has to be so complicated, but I am trying to make a game where I can save what scene the player is on when the game saves, and so that when the player comes back to the game they can load the saved scene.

I don't want to load the player's position on that, I just want it to load to the scene the player last saved on.

How do I do this?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
7

Answer by ralphlizard · May 19, 2016 at 05:56 PM

You can get the index of the current scene with SceneManager.GetActiveScene().buildIndex and save that in PlayerPrefs. When you start the game, you can load the scene using SceneManager.LoadScene(int index). Be sure to have "using UnityEngine.SceneManagement;" minus quotes at the top of the script.

Comment
Add comment · Show 8 · 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 Derpybunneh · May 19, 2016 at 07:56 PM 1
Share

Thank you so so so so so so so so so so much! You saved my butt and my game!

avatar image UpheavalEntertainment · Dec 13, 2016 at 06:45 AM 0
Share

i know this was a long time ago, but what? this sounds like diamonds, can you show me how i would put that into

 public void Save()
     {
         //Scene$$anonymous$$anager.GetActiveScene ().buildIndex;
     }
     public void Load()
     {
         //Scene$$anonymous$$anager.LoadScene();
     }
avatar image Derpybunneh UpheavalEntertainment · Dec 13, 2016 at 02:21 PM 2
Share

Totally! For your save function you'd probably want something like this:

 public void SaveGame() {
         PlayerPrefs.SetInt ("Level", Scene$$anonymous$$anager.GetActiveScene ().buildIndex);
         PlayerPrefs.Save ();
         print ("Game saved!");
     }

And then for your load function you'd want something like this:

 public void LoadGame() {
         Scene$$anonymous$$anager.LoadScene ( PlayerPrefs.GetInt("Level") );
         print ("Game loaded!");
     }

Then if you want the game to save you just call the save function and when you want it to load you just call the load function.

avatar image marcojay Derpybunneh · Jan 22, 2018 at 03:51 PM 0
Share

can i call the load to i\other scene? like in main menu?

Show more comments
Show more comments
avatar image
1

Answer by sr_nada · Oct 12, 2018 at 08:55 PM

Ok, this works well with buttons. But how do I make it work automatically?

Comment
Add comment · Show 1 · 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 Cammant · Oct 12, 2018 at 11:22 PM 0
Share

sr_nada $$anonymous$$aybe put "SaveLoad.Save();" in your main script under the "Update" function? That is what I did.

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

165 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 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 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 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 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 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 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 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 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

How can I save level progression 1 Answer

Having a bit of a problem with loading a save file. 0 Answers

How to save player score? (C#) 0 Answers

How can I save and load datas from multiple objects, that uses different variables from same script?Question (self.Unity3D) 0 Answers

Saving data from multiple game objects 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