我正在研究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