Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Change Scene script and it's not working - how can I fix it ?

Discussion in 'Scripting' started by henningm, Dec 4, 2018.

  1. henningm

    henningm

    Joined:
    Jul 11, 2016
    Posts:
    18
    With this code I shoud schange the scene, but forsome reason I have no idea it's not working.
    Unity save as scene01, scene02 and scene03.

    Must I have camera in every scene (for that I don't have) ?
    In tutorial showe me that they diddn't make more or add it to new scene.

    Code (CSharp):
    1.  
    2. public class ScangeScene : MonoBehaviour
    3. {
    4.  
    5.     //public void ChangeToScene (int sceneToChangeTo)
    6.     public void ChangeToScene(string sceneToChangeTo)
    7.     {
    8.         Application.LoadLevel(sceneToChangeTo);
    9.     }
    10. }
     
    Last edited: Dec 4, 2018
    Deleted User likes this.
  2. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,937
    Deleted User and SparrowGS like this.
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,365
  4. henningm

    henningm

    Joined:
    Jul 11, 2016
    Posts:
    18
    change_scene.png sceneToChangeTo, can't find it so I use name.
    change_scene1.png Squad
    scenemanager.png _Manager
    error changescene1.png error msg, only if am using more than one scene.

    To LurkingNinjaDev: I have unity 2018..2.15f.1 personal.
    To LurkingNinjaDev: Yup, but not saved the build, am just clicked out. I try to save but only asking to load in a folder.

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using UnityEngine.SceneManagement;
    4.  
    5. public class ChangeScene : MonoBehaviour
    6. {
    7.     public void ChangeToScene(string sceneToChangeTo)
    8.     {
    9.         SceneManager.LoadScene(sceneToChangeTo);
    10.     }
    11. }
    12.  
    Any other idea how/what I can use ?

    I found out that the button don't get the message.
    I used "Debug.Log("You Clicked the Button");" and it not respond.


    Ok, I had to make it all from scratch and at last it worked.
    I can't say why it worked now or not the first one.

    This is now solved.
     
    Last edited: Dec 5, 2018