自学Unity又找不到系统的Unity学习,只有各种零碎的知识点,自己做的时候很多需求不知道怎么搞,就记录一下,完全是为了自己方便使用,可能会非常初级,而且不全面,但是没办法,一点一点的积累吧,争取慢慢的补全。
单例模式:
public class GameController : MonoBehaviour
{
private static GameController _instance;
public static GameController Instance
{
get
{
return _instance;
}
}
void Awake()
{
_instance = this;
}
void DoSomething(){
}
}
调用:
GameController.Instance().DoSomething();
本地化存储数据:
PlayerPrefs.GetInt("gold", gold); //其他类型类似
PlayerPrefs.SetInt("gold", 9999);
PlayerPrefs.DeleteAll();// 清除所有数据
加载新