Quantcast
Channel: Questions in topic: "playerprefs"
Viewing all articles
Browse latest Browse all 1333

Problems with my playerprefs. and Level Lock System

$
0
0
I have tried looking up specific codes on the internet but most of the answers i find are too old to use or out of my understanding. Here is some of my code that I think will work if I can figure out what's wrong with it. I am currently making a mobile 2D game so this is probably why it's confusing. ---------- The issues I am having is that levels are all still clickable or you do not have to beat the level to unlock the next one, I placed Lock sprites to make them not interact with them. But this didn't really help lock them. ---------- code using UnityEngine; using UnityEngine.SceneManagement; public class LevelCompleted : MonoBehaviour { public string nextLevel = "Level 2"; public int levelToUnlock = 2; public void LoadNextLevel() { int currentUnlock = PlayerPrefs.GetInt("You win!"); if (currentUnlock < levelToUnlock) { PlayerPrefs.SetInt("You win!", levelToUnlock); } SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1); } }

Viewing all articles
Browse latest Browse all 1333

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>