好房网

网站首页 互联网 > 正文

unity ioexception(unity3d里ArgumentException是什么意思呀?)

2022-05-20 04:47:07 互联网 来源:
导读 相信目前很多小伙伴对于unity3d里ArgumentException是什么意思呀?都比较感兴趣,那么小编今天在网上也是收集了一些与unity3d里ArgumentExce

相信目前很多小伙伴对于unity3d里ArgumentException是什么意思呀?都比较感兴趣,那么小编今天在网上也是收集了一些与unity3d里ArgumentException是什么意思呀?相关的信息来分享给大家,希望能够帮助到大家哦。

如果我没有猜错的话你肯定是在函数外部定义了一个float类型的变量然后直接用Time.time赋值了。

如果是的话那么这段错误完整输出就是:
ArgumentException: get_time can only be called from the main thread.
异常:时间只能被主线程调用。


Constructors and field initializers will be executed from the loading thread when loading a scene.
构造函数和初始域只能在场景加载时被执行。


Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
不要在构造函数或初始化域,你可以把初始化代码移动到 Awake 或 Start 函数中。


你可以这样写,如:
float curTime;
void GetTime()
{
curTime=Time.time;

}
然后在别的地方直接调用GetTime函数就可以了。


说白了就是你不能在函数外部用Time.time直接给变量赋值。

本文到此结束,希望对大家有所帮助。


版权说明: 本文由用户上传,如有侵权请联系删除!


标签:

最新文章: