Load next scene Problem

i have saved all the scene loaders but still next loader which is 3rd one is not showing , it shows play then success button going back to play button . Could you be able help me please

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneLoader : MonoBehaviour
{

    public void LoadNextScene()
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        SceneManager.LoadScene(currentSceneIndex + 1);
    }

    public void LoadStartScene()
    {
        SceneManager.LoadScene(0);
    }
    
}

Hi Rafi,

I’m not sure I fully understand your problem, but, try checking the buttons On Click event handlers in the Inspector, perhaps you have the button wired up to go to the wrong scene.

Hope this helps :slight_smile:


See also;

On Click Event handlers i have done everything is correct after clicking play

image
image

when i play



thats it button goes back to

Hi,

I still don’t think I understand from your “when I play” comment and onwards. Are you saying that when you play the game it jumps straight to the win scene?

when start play
1- start
2-core game
3- win screen

this is the normal which you have done
My Game goes:
1-start
2-core game
3-win screen
then going back to
1-start

So when you arrive at 3-win screen, are you automatically taken to 1-start, or, do you have to press the button?

when start play
1- start
2-core game
3- win screen

this is the normal which you have done
My Game goes:
1-start
2-win screen
3 core game
then going back to
1-start

sorry i forgot to write in order on my game

I see.

So, have a look in the Build Settings and see if you have perhaps got your scenes in the wrong order.

how can i sort it ? order

Select a scene in the Build Settings and drag it up or down to re-order the list.

You code is adding one to the scene’s build index in order to ascertain the next scene index to load. If you look in the Build Settings you’ll see the scene indexes on the right hand side of the scenes pane.

You’ll want them to be like this;

Start - index 0
Core Game - index 1
Win Screen - index 2

So, you progress from index 0 to index 1 when you click Play on the Start scene
You then progress to index 2 when you click “That’s It!” on the Core Game scene
When you click “Play Again” on the Win scene you need to loop back round to index 0, which is what your LoadStartScene method should be doing.

1 Like

thank you you are legend :wink:

1 Like

You’re very welcome - let me know if this resolves the issue for you :slight_smile:

done Perfect :wink:

1 Like

Great to hear Rafi, I will mark this topic as solved then, link below for. Future reference for yourself :slight_smile:


See also;

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms