How to CHANGE SCENE BY NAME when pressing BUTTON in Unity - Download included

Опубликовано: 03 Ноябрь 2024
на канале: GDT Solutions ES
54,854
899

In this video we see a simple way to change to any scene using buttons in Unity, using the name of the scene we want to switch to as a parameter.
To do this we will create a Script with a function that does the job and then make each button execute that function but passing as a parameter the name of the scene it has to load. In this way we can load any scene when we press the button using only one Script.
It is important that the scenes are added to the compilation, otherwise they cannot be loaded. To do this you have to open each scene, go to File - Build Settings and click on "Add Open Scenes".

DOWNLOAD UNITY PACKAGE 👉 https://gamedevtraum.itch.io/load-sce...

____________________________________________________________
LINKS

Portfolio: https://gamedevtraum.com/en/portfolio...

LinkedIn:   / gamedevtraum  

Downloads: https://gamedevtraum.itch.io/

Contact:   / gamedevtraum  
____________________________________________________________

TIMESTAMP
00:00 Intro - DOWNLOAD PACKAGE
00:21 Add all the scenes in BUILD SETTINGS
00:45 Create a script to SWITCH SCENES
00:55 Implement NAMESPACE and define this public function
01:23 Instruction that changes the scene
01:39 ASSIGN THE SCRIPT to a GameObject in the hierarchy
01:49 Make the BUTTONS use the script to LOAD SCENES
02:30 Test 1 OK
02:43 Test 2 ERROR - Scene not added in Build Settings
03:08 Same as before, configure the buttons in the other scenes

#EN