**Why if (PlayerPrefs.HasKey ("Level")) Doesn't Work**
void Start ()
{
playerInZone = false;
}
// Update is called once per frame
void Update ()
{
if (playerInZone)
{
PlayerPrefs.SetInt ("Level", ThisLevel);
Application.LoadLevel (levelToLoad);
}
}
void OnTriggerEnter2D(Collider2D other)
{
if (other.name == "Player")
{
playerInZone = true;
}
}
void OnTriggerExit2D(Collider2D other)
{
if (other.name == "Player")
{
playerInZone = false;
}
}
}
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if (PlayerPrefs.HasKey ("Level"))
{
LevelReached = PlayerPrefs.GetInt ("Level");
if (LevelReached >= ThisLevel)
{
LevelUnlock ();
}
}
}
void LevelUnlock ()
{
GetComponent
↧