Questions tagged [scene-manager]

class in UnityEngine.SceneManagement for managing scenes in unity

56 questions
4
votes
3 answers

How to fix unintended scene buildIndex of -1 in Unity

Essentially, after testing a few level prototypes, I've decided to stick with my current game idea so I started creating a GameManager to control the flow of levels, etc. I don't have any additional libraries or asset packages being used outside of…
4
votes
1 answer

SceneManager doesn't get Scene by name

I have 3 scenes in my Unity project and trying to get a scene index by its name. I'm trying to use SceneManager but I can't figure out how to use SceneManager.GetSceneByName . Using SceneManager.GetSceneByName("Scene1"); returns null while I can…
Ghasem
  • 14,455
  • 21
  • 138
  • 171
3
votes
1 answer

How to preserve the full state of objects between scenes?

When loading a new Scene I run into the trouble of having my mouse drag not carry over to the next scene and having to re-click when the new scene is loaded. I would like the mouse click to carry over seamlessly to the next scene without the player…
Maurice Bekambo
  • 325
  • 6
  • 21
2
votes
1 answer

Empty Scene is taking time to unload in Unity

I have a normal project with about 30 Scripts and 30 Scenes (approx). When unloading any scene, it takes about 2 seconds. For testing, I have made 2 empty scenes with 1 button each and want to transition back and forth. But again the Scene unload is…
Junaid Pathan
  • 3,850
  • 1
  • 25
  • 47
2
votes
2 answers

How to prevent the reload of already loaded gameobjects in Unity?

I'm currently developing a game in Unity and I ran into a small problem. I'm working on a restart function that gets called automatically when the player dies and loads the first scene again. However for some reason when reloading the scene games…
2
votes
2 answers

Unity scene switching takes too much time

I have created a game with a main menu in a scene and I have a second scene that has the actual game in it. When the user taps the play button on main menu scene it loads the actual game scene but the problem is that it takes too much time. What…
Fazil Mahesania
  • 101
  • 1
  • 3
  • 18
1
vote
1 answer

Player movement doesn't work after reloading the scene in Unity

Using Unity 2021.3.16f1. I followed this tutorial from Brackeys to make the pause menu for my flappybird like game, my player movement stops working after I exit the main game to the main menu and return to the game. Part of player code responsible…
Jopeez
  • 13
  • 4
1
vote
1 answer

Simulating a second, hidden physics scene into the future on a single frame to predict the trajectories of planets?

I want to simulate the trajectories of planets in a seperate scene to find out where they will be in the future. I drew a quick diagram to demonstrate. Is there a way to simulate 2 scenes separately, hiding one but showing the other? I tried this…
1
vote
1 answer

Load Scene is not restarting the scene properly

I'm trying to restart my game when the player loses, I play a coroutine which makes the player ignore collisions and falling off the platforms. Then when the player click a button, the same scene is reloaded. SceneManager.LoadScene("GameScene") But…
adrian
  • 97
  • 2
  • 12
1
vote
1 answer

UnityException: GetActiveScene is not allowed to be called from a MonoBehaviour constructor

I'm trying to make a save level system and I keep on getting this error. UnityException: GetActiveScene is not allowed to be called from a MonoBehaviour constructor I've tried searching this up, but there were no results. Here is the code I…
1
vote
2 answers

checkpoints c# in unity

i am making a game with c# in unity and i want that if you die in level 4 that you go back to level 0 but if you are in level 5 that you respawn in level 5 the code: { int currentSceenIndex = SceneManager.GetActiveScene().buildIndex; …
kajvans
  • 85
  • 6
1
vote
0 answers

Unity start() called before scene is fully loaded

I ran into this article Multi-scene editing, and at the bottom of the tips and tricks section, there's the following sentence: "It is recommended to avoid using DontDestroyOnLoad to persist manager GameObjects that you want to survive across scene…
Thrindil
  • 143
  • 3
  • 17
1
vote
1 answer

Saving all scene content through script

I've been working on a game, and one of its features is being able to create a level. However, I'm having some trouble on how to save the level the user has created. I'm thinking of duplicating the scene the player is working on when they hit the…
1
vote
1 answer

How can adapt my object pooler to reset for each new scene that I load?

After updating the game according to the specifications given in the answer I now get the following error message: Assets\ObjectPooler.cs(79,41): error CS0103: The name 'pool' does not exist in the current context. I understand why it doesn't work…
1
vote
2 answers

How to access gameobject present in another scene

I am creating a simple number guessing game in unity3d. I want to open a new scene on button click and change the text of a text element present in the loaded scene from the current scene. I have been able to open new scene on button click but how…
user7500403
1
2 3 4