Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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
0
Question by gustavim15 · Sep 25, 2016 at 07:36 PM · sceneloadlevelasyncmanagementunload

How to Reload a Scene but keeping others already Loaded Scenes?,How to Reaload a Scene and keep others Loaded Scenes without unload then?

Hi...

My game level is composed of many scenes. So, if my player dies, I just reload that scene he was and not all the level, because he can go backwards if he want. But there is the problem... I go playing and loading the scenes. But when I die and reload that scene I was, the other scenes just unload.

If someone could help me... Thank you, and sorry my bad english.,

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
1
Best Answer

Answer by TBruce · Sep 25, 2016 at 08:33 PM

When loading a scene do it like this

 SceneManager.LoadScene(SceneToLoad, LoadSceneMode.Additive);
Comment
Add comment · Show 7 · 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 gustavim15 · Sep 25, 2016 at 08:50 PM 0
Share

I'm already doing it... But think with me... I'm used it 3 times, so I have 3 Loaded Scenes... If I die, I want to load the scene that I was, but keep intact the other 2 scenes, understand? Thank you for your attention @$$anonymous$$avina

avatar image TBruce gustavim15 · Sep 25, 2016 at 08:58 PM 1
Share

What do you mean but keep intact the other 2 scenes?

Also, you may want to do more than just the LoadScene call. for example

 void LoadScene(string SceneToLoad)
 {
     Scene scene = Scene$$anonymous$$anager.GetSceneByName(SceneToLoad);
     if ((scene != null) && (!scene.isLoaded))
     {
         Scene$$anonymous$$anager.LoadScene(SceneToLoad, LoadScene$$anonymous$$ode.Additive);
     }
 }
avatar image TBruce TBruce · Sep 26, 2016 at 01:43 AM 2
Share

That is your game data. You need to come up with a system to save your game data for each scene. When a scene loads you will load the game data. The game data can be saved a different intervals during a game.

The class that allows you to do that is called PlayerPefs. It also allows you to set defaults (which works great when first loading a scene and the values do not exist yet.

For example take this class Scene$$anonymous$$anager, it also requires this library. Add this class to a game object in each scene. Set the appropriate variables in the inspector. These are the functions in Scene$$anonymous$$anager

  1. PuzzleSolved()

  2. EnemyDie()

  3. OnApplicationQuit()

  4. LoadSceneData()

  5. SaveEnemyData()

  6. SavePuzzleData()

  7. SaveSceneData()

Show more comments
avatar image gustavim15 · Sep 26, 2016 at 11:41 AM 0
Share

Hmmm, what a perfect answer @$$anonymous$$avina Now I see what I'll need to do to have it working like I want. I'll always have to load my scenes, but with a game data to control how it will be loaded (With enemys dead or not, puzzles done or not, this stuffs...) Thank you for your help and your time!

avatar image TBruce gustavim15 · Sep 26, 2016 at 09:41 PM 1
Share

I am sorry I did not have a chance to test the code I gave you last night and found it was riddled with errors, though I do see that you got the gist of it.

But I went and fixed the errors and here is the class. It has been tested and works out of the box, all you need to do is set the appropriate variables in the inspector.

I had to change the name Scene$$anonymous$$anager to Scene_$$anonymous$$anager because Scene$$anonymous$$anager is a Unity class. I also added the randomization of the prefab position and rotation on instantiation.

avatar image gustavim15 TBruce · Sep 27, 2016 at 12:10 AM 0
Share

Yes, I really got the gist of it... For sure this code will help me a loooot!

Thank you one more time.

avatar image
0

Answer by FranSabba · Feb 21, 2021 at 12:01 AM

Same issue, just Load the same scene doesn't work, you need to unload previous scene or you will have 2 of the same scenes loaded. The problem is that I can't unload an scene with the same name and index...

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

75 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

Related Questions

Load Scene in Background and Load When a Button is Clicked 0 Answers

Correct use of Application.UnloadLevel ? 1 Answer

Simple - Save and Loading Scene 0 Answers

Is true async scene loading possible? 0 Answers

Async Level loading issue. 0 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