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. Dismiss Notice

Resolved Loading And Unloading Scenes Issue

Discussion in 'Scripting' started by nathukadevyt, Jun 5, 2021.

  1. nathukadevyt

    nathukadevyt

    Joined:
    Mar 28, 2021
    Posts:
    17
    Hello, I'm currently working on A Rhythm Based RPG game and am trying to make a simple Scene Switch when 2 gameObjects Collide (OnCollisionEnter2D)

    Im using "SceneManager.LoadScene" (Which is shown on the official blog, which I checked after receiving the error) and it's saying "'Scene Manager' does not contain a definition for 'Load Scene'. I also tried using 'SetActiveScene' but that didn't work either :/

    Here is my code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class ReactionsOnCollisions : MonoBehaviour
    7. {
    8.     private void OnCollisionEnter2D(Collision2D collision)
    9.     {
    10.         if (collision.gameObject.CompareTag("SceneLoader1"))
    11.         {
    12.             SceneManager.LoadScene("Rythm1");
    13.         }
    14.     }
    15. }
    16.  
    Anyone who could point out my error and provide a valid Scene-Switching C# syntax would be greatly appreciated! :)
     
  2. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,144
    Do you have another script called "SceneManager"?
     
  3. nathukadevyt

    nathukadevyt

    Joined:
    Mar 28, 2021
    Posts:
    17
    Yes, I do. And Now I realise the reason my Script didn't work. Thanks for your help!
     
    Kurt-Dekker likes this.