Home>

unity version: 2018.2


The photo is a capture of the start screen (scene 1).
"Game flow (1)", "Operation method (2)", and "Start (3)" are buttons.

Build setting is
Scene 1, scene 2, scene 3, and scene 4 are set. (From left to right)

I want to solve
・ ① → Scene 2 → Scene 1
・ ② → Scene 3 → Scene 1
・ ③ → Scene 4 → Scene 1
I want to switch scenes like
When each button is pressed, all transitions to scene 2.

Is the build setting wrong?

Is there another way to switch screens?

I would appreciate it if you could tell me.

Supplement

The source code that is switching scenes.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneManagerSecond: MonoBehaviour
{

// Use this for initialization
void Start ()
{

}

// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown (0)) // Left click
{
SceneManager.LoadScene ("Scene name");// Scene switch
}
}
}

  • Answer # 1

    // Update is called once per frame
       void Update ()
       {
           if (Input.GetMouseButtonDown (0)) // Left click
           {
               SceneManager.LoadScene ("Scene name");// Scene switch
           }
       }

    The above will switch to the scene written in"scene name", regardless of where you click.

    It is common to add processing toOn Click ()as shown here for the processing you want to run when the button is clicked.


    When describing the source code, enclose it with "` "" x 2 for easier viewing.