How do I fix my unity play button script? it was working before

Viewed 104

How do I fix this it was working before but it broke somehow:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SM_SceneSwitcher : MonoBehaviour {
  public void playGame()
    {
     SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); 
    }
    public void Back()
    {
        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);
    }
1 Answers

I guess your script is not attached to the game object anymore ?

This happens if you rename or move your script, your button still references the old path, you need to put your script again in your button

This, or the playGame and Back functions are not assigned to the click action.

Related