Hello! I was wondering if it's possible to call LoadLevel or another similar Sequence command to load the next scene listed out in the build settings, without having to specify the scene/level name.
The reason I want to do this is to use the same conversation for all scene transitions since I'll have many scenes. This way I won't have to create a conversation for each scene transition where the scene/level name has to be specified in the command.
Thank you for your help!
Set Sequence Command LoadLevel to always load the next scene in the build settings
-
- Posts: 11
- Joined: Thu Dec 29, 2022 3:58 pm
Re: Set Sequence Command LoadLevel to always load the next scene in the build settings
Hi,
If you want to use the existing LoadLevel() sequencer command, you can use a Dialogue System variable. In LoadLevel(), you can specify a build index instead of a scene name by putting "index:" in front of the build index, such as:
LoadLevel(index:2)
Let's say you have a variable named sceneIndex. You could set up a dialogue entry like this:
If you want to use the existing LoadLevel() sequencer command, you can use a Dialogue System variable. In LoadLevel(), you can specify a build index instead of a scene name by putting "index:" in front of the build index, such as:
LoadLevel(index:2)
Let's say you have a variable named sceneIndex. You could set up a dialogue entry like this:
- Dialogue Text: "Take me to the next scene."
- Script: Variable["sceneIndex"] = Variable["sceneIndex"] + 1
- Sequence: LoadLevel(index:[var=sceneIndex])
-
- Posts: 11
- Joined: Thu Dec 29, 2022 3:58 pm
Re: Set Sequence Command LoadLevel to always load the next scene in the build settings
Hi Tony, I apologize for the late response, I took a break from coding. Thanks for your help.
I tried running
but it printed an error saying "Scene 'index:1' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded.".
So I tried running
but getting the same error.
I attached a picture of my build settings. It has two scenes so I expected "LoadLevel(index:1)" to work but not sure why it's erroring. Would you know why?
Thanks again for your help.
I tried running
Code: Select all
LoadLevel(index:[var=sceneIndex])
So I tried running
Code: Select all
LoadLevel(index:1)
I attached a picture of my build settings. It has two scenes so I expected "LoadLevel(index:1)" to work but not sure why it's erroring. Would you know why?
Thanks again for your help.
- Attachments
-
- Capture.PNG (8.07 KiB) Viewed 1034 times
Re: Set Sequence Command LoadLevel to always load the next scene in the build settings
Hi,
To use the "index:#" format with LoadLevel, make sure you've set up the save system. Otherwise it will use Unity's plain old SceneManager.LoadScene("name") which doesn't understand "index:#".
To use the "index:#" format with LoadLevel, make sure you've set up the save system. Otherwise it will use Unity's plain old SceneManager.LoadScene("name") which doesn't understand "index:#".
-
- Posts: 11
- Joined: Thu Dec 29, 2022 3:58 pm
Re: Set Sequence Command LoadLevel to always load the next scene in the build settings
Yes, that fixed it! Thank you for your help once again.