How do you merge two scenes together in Unity?

I completed the 2D microgame platformer tutorial some time ago. At the end of the game, there’s a door that marks the scene as completed. I want to create my own scene, so that when you enter the door, the player character gets transferred to the new scene that I have created.

How do you do that?

Your script calls SceneManager.LoadScene() with the index or name of the scene. Note that only scenes actually listed in the Build Settings will be included in your built game, and it’s those index numbers which you use for this function.

Any data that you want to carry over should be in a static object, a singleton, or in a GameObject which you have marked as “Don’t Destroy On Load,” aka DDOL, using the Object.DontDestroyOnLoad() function.

1 Like

Okay, is there no easy way to do it, other than using scripts?

If not, then I will have to watch a few tutorials on how to do scripts first.

Focus on making the character moving to the new scene first. Worry about what information you may need from the former scene after that. Some items could probably just be copied from the first scene.

Find info on the ontrigger event, and the SceneManager functions mentioned above.

I have already made the character move to the door that finishes the first scene, if that’s what you mean?

when he is at the door, do you have something that confirms this? like a gameobject with ontrigger function?

Yes. In Assets > Scripts > Mechanics, there is a script called VictoryZone.cs, which marks the scene as completed.

9270342--1298160--Victory Zone.jpg

Assuming it has an if-statement for confirming the victoryzone is reached, you could put the SceneManager.LoadScene(scenename/sceneid here) command inside that statement.

How do I that?

Should I click open and put it in the VictoryZone.cs script manually?

I hope it’s okay that I ask, as this is a bit of a new territory for me.

Are my screengrabs helpful?

I just tried typing SceneManager.LoadScene Start (that’s the name of the new scene) into the VictoryZone.cs script.

I now get these error messages:

You can’t put code just anywhere.
move the scenemanager command inside that if-loop, below ev.victoryZone = this

and don’t forget the ; at the end

I recommend taking some basic coding tutorials. Here’s an awesome place to start:

And for the love of all that is holy, write your code with a proper IDE like Visual Studio. Trying to code without autocomplete and error highlighting is sheer madness, especially if you’re a complete beginner. The Junior Programmer course linked above should cover this as well.

I have Visual Studio for Mac installed, if that’s what you mean?

Also, I will take a look at the Junior Programmer Pathway.