- Home /
making a level not play able until a level is beaten
I am using a script to load my levels but i can't figure out how to make them not active until for instance level 1 is beaten. Only then you could play level2 and so on.
var levelToLoad : String;
var soundhover : AudioClip;
var beep : AudioClip;
var QuitButton : boolean = false;
function OnMouseEnter(){
audio.PlayOneShot(soundhover);
}
function OnMouseUp(){
audio.PlayOneShot(beep);
yield new WaitForSeconds(0.35);
if(QuitButton){
Application.Quit();
} else{
Application.LoadLevel(levelToLoad);
}
}
@script RequireComponent(AudioSource)
var levelToLoad : String; var soundhover : AudioClip; var beep : AudioClip; var QuitButton : boolean = false; function On$$anonymous$$ouseEnter(){ audio.PlayOneShot(soundhover); } function On$$anonymous$$ouseUp(){ audio.PlayOneShot(beep); yield new WaitForSeconds(0.35); if(QuitButton){ Application.Quit(); } else{ Application.LoadLevel(levelToLoad); } } @script RequireComponent(AudioSource)
FOR$$anonymous$$AT YOUR CODE AND PUT IT IN THE QUESTION.
Answer by behzad.robot · Apr 13, 2013 at 04:22 PM
Check about this in unity scripting refrence :
print (PlayerPrefs.GetInt("LastLevelopen"));
Check more about PlayerPrefs there u can simply get this number and then u know which level to load then make it one more when the player has bitten a new level! (by reading it frist and then putting ++ of it with SetInt for sure :D)this thing will be uniqe for each computer even if ur game is portable :O .
Your answer
![](https://koobas.hobune.stream/wayback/20220613100235im_/https://answers.unity.com/themes/thub/images/avi.jpg)