- Home /
Help please guys thank you so much!
Hello, so I have the follow code here: using UnityEngine; using System.Collections;
public class GameManager : MonoBehaviour { public int forcurrentscore; public int highscore; public int currentlevel = 0; public int lockedlevel;
void CompleteLevel()
{
currentlevel = +1;
Application.LoadLevel(currentlevel + 1);
}
} The line that says "Application.LoadLevel(currentlevel + 1);" has an error saying that "Application.loadlevel(int)' is obsolete: Use Scencemanager.Loadscene". And when I am trying to call this void function from another script using the following code: void OnTriggerEnter(Collider other) { if (other.transform.tag == "Goal") { GameManager.CompleteLevel(); } } An error comes up saying: 'GameManager.CompleteLevel()' is inaccessible due to its protection level. What do you guys recommend me to do? Thank you for your help! I am using C# by the way.
Answer by HarshadK · May 04, 2016 at 01:29 PM
Change the title of the question to something proper.
Use SceneManager.LoadScene instead of Application.LoadLevel(int).
You need to make your CompleteLevel() method public as:
public void CompleteLevel()
Your answer
Follow this Question
Related Questions
Help with basic AI script 1 Answer
Why is this error coming up in my code ? 1 Answer
Distribute terrain in zones 3 Answers