unity实现“使用次数限制时间限制”功能
int count = 0;
void Start()
{
//限制本地访问exe次数
if (PlayerPrefs.GetInt("count") > 30)
{
Application.Quit();
}
count= PlayerPrefs.GetInt("count");
count+= 1;
PlayerPrefs.SetInt("count", count);
}
void Update()
{
//限制时间
if (System.DateTime.Today.Year > 2019)
{
Application.Quit();
}
else
{
if (System.DateTime.Today.Month > 3)
{
Application.Quit();
}
else
{
if (System.DateTime.Today.Day > 31)
{
Application.Quit();
}
}
}
}