'How do I fix my unity play button script? it was working before
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);
}
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mmarie4 |
