Search Unity

SceneManager/GetActiveScene

Discussion in 'Scripting' started by arrowman888, Jul 29, 2018.

  1. arrowman888

    arrowman888

    Joined:
    Mar 13, 2015
    Posts:
    6
    I have been trying to use GetActiveScene for the past 15 minutes but anyway I tried did not work. So finally I gave up and decided to cope what the unity manual gives, but still no solution I just keep getting the same error. I am at a loss and have no idea where to go from here... any help is appreciated. Ignore the variables they're for the rest of this script.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.UI;
    5. using UnityEngine.SceneManagement;
    6.  
    7.  
    8.  
    9. public class SceneManager : MonoBehaviour
    10. {
    11.  
    12.     //position of rocket x = -23.21 y = 1.52 z = 7.26
    13.  
    14.     public float time = .90f;
    15.     public GameObject game;
    16.     public GameObject rocky;
    17.     public GameObject startPoint;
    18.     public GameObject endPoint;
    19.     bool abled;
    20.     public Text winText;
    21.     public Text loseText;
    22.     int Win_Lose;
    23.     public GameObject FirCoin;
    24.     public Text theScore;
    25.     int yourScore;
    26.     public Text GetKey;
    27.     int maxScore;
    28.  
    29.     void Start()
    30.     {
    31.         Scene scene = SceneManager.GetActiveScene();
    32.         Debug.Log("Active scene is '" + scene.name + "'.");
    33.     }
    The error is:
    `SceneManager' does not contain a definition for `GetActiveScene'
    Thanks!
     
  2. Doug_B

    Doug_B

    Joined:
    Jun 4, 2017
    Posts:
    1,596
    This is because you have overwritten Unity's SceneManager with your own at line 9. Your version does not contain that method. Change your class name to something else, for example,
    MySceneManager
    .
     
    arrowman888 likes this.