Categories
Uncategorized

Scene Transition function

This week, I updated the script of the VR music game project. I added a scene transition function and made several new scenes. The main purpose of the scene transition function is that when the player wants to switch levels or return to the operation interface, the script can help the player to interact by pressing buttons.
The main syntax of scene interaction can be completed by the built-in components in Unity. As shown in the figure, we only need to add the following code to the button key to realize the conversion of the specified scene or interface.

Change the scene

For unity scene conversion, we can also perform a scene conversion by looking up the scene index value through code.

Use the scene index to Change the scene

For the second method, we need to create a new scene and get the index value of this scene. We can find the Build Setting from the File option in Unity, and then we can see from the Build Setting that the scene is the index value. Creating a new scene is very simple, the programmer can directly create an empty scene in the Unity folder, or create a scene with a camera and basic light source in the function key.

We can see the numbers 0 and 1 after the file name, that is the index value of the scene, we only need to add the index value in the script to the place where we want to convert, then the script will switch the scene through the player’s interaction .

The realization of scene conversion can help developers better distribute work. Each person can change at will in the scene he is responsible for, and then associate through buttons or icons. This can avoid unnecessary errors when multi-person teams work at home and upload code. They can use git to load the same Unity file for work and upload at any time.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *