Hello,
I have a problem adding buttons to prefab.
I have several levels that are currently locked. The level buttons are locked with another button that on click open PopUp. In a PopUp is another button where on click unlock selected level (or sets the button to inactive). The problem is that Prefab doesn't save my button as inactive and every time I open it the "Locked Button" is active.
Who can help me?
Thanks everyone!
My code:
public class UnlockLevel : MonoBehaviour
{
public List unlocked;
public List LevelButton;
int i;
public void Unlock(int level)
{
LevelButton[i++].gameObject.SetActive(false);
PlayerPrefs.GetInt("Levels",i);
}
public void EnterLevel(int level)
{
if (unlocked[level] == true)
{
PlayerPrefs.SetInt("Levels", i);
}
}
}
↧