- Home /
Max Level reached ever
I make a game with more levels. (50). In my main menu is an option ChooseLevel. When you can tipe in a InputField a level number and that level will start. I want to show in a GUIText an error message if the level number is less than the max level ever reached. Like i play up to level 20 and when i type in InputField 30 to show a msg "This level is locked".
O$$anonymous$$, and what's stopping you? You've not asked a question...
Answer by tigertrussell · Apr 04, 2015 at 11:24 PM
I think you are looking for PlayerPrefs, which will allow you to store the highest level that your player ever completes.
For instance you might have some function in your gameplay manager:
//This would perhaps be called from BroadcastMessage() or something elsewhere in your game
public void OnLevelComplete() {
PlayerPrefs.SetInt("HighestLevelAchieved", this.myLevelId);
}
Then when you need to check...
public bool IsLevelAvailable(int n) {
return n >= 0 && n <= PlayerPrefs.GetInt("HighestLevelAchieved", 0);
}
So now you can easily determine whether the level is unlocked or not.
If you're asking about the GUI stuff you should fix your question.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
TMP_Input Field Destroys text 2 Answers
Working Browser for In-Game PC. 0 Answers
Create an InputField in 3D space 1 Answer