using UnityEngine;
using System.Collections;
int Level0 { get; private set; }
public class PlayButton : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
public void OnMouseUp() {
Application.LoadLevel(Level0)
}
When I try to attach it to the button, I get the CS8025 error. What is the problem?
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
public class PlayButton : MonoBehaviour
{
public int Level0;
public void OnMouseUp() {
SceneManager.LoadScene(Level0);
}
}
CS8025 is a parsing error. But that’s not the only issue with this script…
-
there’s needs to be semi-colon after LoadLevel. Should be like this:
Application.LoadLevel(Level0);
-
You didn’t say what version of Unity you were using, but if using a recent version, then LoadLevel will be deprecated, it needs to be loaded with SceneManager;
SceneManager.LoadScene(Level0);
-
void OnMouseUp function needs to encapsulated in the class.
-
the Level0 property needs to be encapsulated in the class, also it should be public. It doesn’t need getter/setters.
https://unity3d.com/learn/tutorials/topics/scripting