我试过很多方法,但我真的无法理解。这是我制作的关卡锁定/解锁系统。在我的电脑上工作完美,但当我在我的Android智能手机上测试它没有任何作用。为什么?如果我将使用PlayerPrefs将工作?我应该如何使用PlayerPrefs?因为我在很多方面尝试过而没有结果。
这是我的剧本:
using UnityEngine;
using System.Collections;
public class LevelLockSystem : MonoBehaviour {
public GameObject unlockLevel2;
public GameObject unlockLevel3;
public GameObject unlockLevel4;
public GameObject unlockLevel5;
public GameObject unlockLevel6;
public GameObject unlockLevel7;
public GameObject unlockLevel8;
public GameObject unlockLevel9;
public GameObject unlockLevel10;
public void Start()
{
}
public void LockAllLevels()
{
unlockLevel2.SetActive(true);
unlockLevel3.SetActive(true);
unlockLevel4.SetActive(true);
unlockLevel5.SetActive(true);
unlockLevel6.SetActive(true);
unlockLevel7.SetActive(true);
unlockLevel8.SetActive(true);
unlockLevel9.SetActive(true);
unlockLevel10.SetActive(true);
}
public void UnlockLevel2()
{
unlockLevel2.SetActive(false);
}
public void UnlockLevel3()
{
unlockLevel3.SetActive(false);
}
public void UnlockLevel4()
{
unlockLevel4.SetActive(false);
}
public void UnlockLevel5()
{
unlockLevel5.SetActive(false);
}
public void UnlockLevel6()
{
unlockLevel6.SetActive(false);
}
public void UnlockLevel7()
{
unlockLevel7.SetActive(false);
}
public void UnlockLevel8()
{
unlockLevel8.SetActive(false);
}
public void UnlockLevel9()
{
unlockLevel9.SetActive(false);
}
public void UnlockLevel10()
{
unlockLevel10.SetActive(false);
}
}