- Home /
,Block Levels and save progress
I would like to save the progress of the player and block the levels in which he has not yet arrived, but I would like this progress not to disappear when restarting unity.
I thought about creating a script by taking the stage name and using (example):
using UnityEngine; using System.Collections;
public class Blocklevel : MonoBehaviour {
void Awake () {
DontDestroyOnLoad(transform.gameObject);
if (progress == "Phase Name")
{
block the following levels in menu
}
} }
Loads of examples and tutorials on this topic. Here is one from the unity website:
Answer by imrankhanswati · Nov 25, 2017 at 07:09 PM
Hello @unity_Y19j_WqZ7S9TLQ ....
About locking or blocking the level you can use unity "Playerprefs" . which will save your data permanently. so by doing this create two scripts in which one will be holding data for playerprefs and other script will be using that data. by the way you can do it in only one script but in long run it will make problems for you so i will strongly suggest to keep your playerprefs in separate script. example scripts: I uploaded the sample script in png form. I think this might help. And if you need more help about locking and unlocking level you can watch this video "https://youtu.be/AQpDtrNJAEU".
[2]: /storage/temp/106226-lock-unlockl-evel.png