- Home /
The question is answered, right answer was accepted
CS8025 error on play button
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?
Answer by Jessespike · Oct 07, 2016 at 08:13 PM
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.
Gives error CS0103. says Scen$$anonymous$$anager does not exist in this context. using UnityEngine; using System.Collections;
public class PlayButton : $$anonymous$$onoBehaviour { public int level0;
public void On$$anonymous$$ouseUp() {
Scene$$anonymous$$anager.LoadScene(level0);
}
}
Now it gives me CS0103: the name "Scene$$anonymous$$anager" does not exist in the current context. This is what it looks like;
using UnityEngine;
using System.Collections;
public class PlayButton : $$anonymous$$onoBehaviour { public int level0;
public void On$$anonymous$$ouseUp() {
Scene$$anonymous$$anager.LoadScene(level0);
}
}