在我将使用 Unity 开发的项目中,我需要立即检查来自 Web 服务的数据。如果输入了新的数据,我会将其显示为通知。
问题是:Unity如何在后台检查来自Web服务的数据?我必须这样做,而无需在服务器上安装大量负载。
谢谢你。
在我将使用 Unity 开发的项目中,我需要立即检查来自 Web 服务的数据。如果输入了新的数据,我会将其显示为通知。
问题是:Unity如何在后台检查来自Web服务的数据?我必须这样做,而无需在服务器上安装大量负载。
谢谢你。
Unity 有一个可以使用的InvokeRepeating方法,它会每隔 x 秒调用一次函数。这是与 StartCoroutine 一起使用时的示例代码:
void Start()
{
//Call the CheckForUpdates function every 5 seconds
InvokeRepeating("CheckForUpdates", 5.0f, 5.0f);
}
private void CheckForUpdates()
{
StartCoroutine(
webservicesAPIcall()
);
}
private IEnumerator webservicesAPIcall()
{
//make API calls to the web service in here
}