我正在研究Unity3D应用程序,该应用程序基本上从服务器获取数据并尝试在运行时创建对象。当我试图创建该对象,通过对我定义一些类构造函数,我得到以下错误:在运行时创建对象
get_name 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
我不能把这移动到任何醒着还是开始,因为我需要一些反馈我运行所提到的代码之前我的GUI(用户凭据)。
任何意见/建议?
如果您需要凭据,为什么将逻辑放入构造函数中?将代码移动到自定义方法中,并在用户执行所需操作并调用其输入时调用它 – 2014-10-27 15:42:56
位于类的构造函数中我试图实例化,而不是场景的构造函数等。对于混淆,抱歉。 – javydreamercsw 2014-10-27 16:24:32