Others unity issue

Sebbycus

New Member
May 29, 2019
2
0
So i have code in my project that states when the end of the stage is reached, it takes the build list number, adds one, and takes you to that scene. but for some reason, no matter what i try, upon completing the first stage, it goes to the third stage. after that the code works fine, its just the start and i cant find any reason why



this is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class WinZone : MonoBehaviour {

public void OnTriggerEnter2D (Collider2D other)
{
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex + 1);
}
}

i've asked some people i know and they have no idea why this issue exists, given the fact it works fine after the first transfer of scenes. if anyone can help it'd be great.
 
Last edited:

Elvishious

Afterglow Developer
Game Developer
Mar 9, 2018
149
419
Can you go in File>Build settings
318023
And verify that all your scenes are in there? If not, drag/drop you scenes there.
Also make sure they are ordered as intended for you (drag/drop to switch position).

You may also need to make something to prevent going out of bond: verify if the build index you want to load exist before LoadScene(buildindex).
You should use for that.

If doesn't work properly, try instead.
 
Last edited:

Sebbycus

New Member
May 29, 2019
2
0
Can you go in File>Build settings
View attachment 318023
And verify that all your scenes are in there? If not, drag/drop you scenes there.
Also make sure they are ordered as intended for you (drag/drop to switch position).

You may also need to make something to prevent going out of bond: verify if the build index you want to load exist before LoadScene(buildindex).
You should use for that.

If doesn't work properly, try instead.
All the scenes are there, and in the right order.
i didnt know you could actually check to see if the index existed or not, i'll give that a try
cheers for the help