Search Unity

Question how do i swtich scenes in c#?

Discussion in 'UGUI & TextMesh Pro' started by EnderCal1012, Jun 24, 2022.

  1. EnderCal1012

    EnderCal1012

    Joined:
    May 3, 2022
    Posts:
    1
    Im trying to use a textmesh pro UI button to switch to a scene using C# script. Is there anyone who can help?
     
  2. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    487
    Pretty sure TMP has its own subforum, still answering.
    1. Make a new script
    2. Implement stuff from here: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html
      Make sure to have a method that accepts an argument of type string (if you use the name to load the scene) or int (if you use the index)

    3. Add the script to your button
    4. In the Click event field, add a reference to your script and select the method that changes the scene
    5. Fill in the parameter