If you reach the finish of level 1, the playerpref: Level1Done will be set to 1. So that number must be constantly updated. If you press the button of level 2, but you havent reached the finish of level 1. Unity won't load scene level 2.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GoToLevel2 : MonoBehaviour
{
void Update()
{
int Kaas = PlayerPrefs.GetInt("Level1Done");
}
public void GoToLevelTwo()
{
if (Kaas == 1);
{
SceneManager.LoadScene("Level 2");
print("hudhunluhdc");
}
}
}
↧