Unity 解决“... can only be called from the main thread”问题

简介: “... can only be called from the main thread”

1.下载这个插件

地址:https://github.com/PimDeWitte/UnityMainThreadDispatcher

image.png2.拖拽添加进unity

image.png

3.创建空对象挂载脚本

image.png

4.在需要用到的地方加入

UnityMainThreadDispatcher.Instance().Enqueue(() =>{
//你的代码});


相关文章
|
8月前
|
Python
python RuntimeError: main thread is not in main loop
python RuntimeError: main thread is not in main loop
203 1
|
8月前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
174 1
|
开发工具
【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)
【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)
874 0
【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)
已解决 RuntimeError: There is no current event loop in thread ‘Thread-1‘.
Jetson Xavier NX 报错 RuntimeError: There is no current event loop in thread 'Thread-1'.异常错误,已解决
660 0
已解决 RuntimeError: There is no current event loop in thread ‘Thread-1‘.
|
开发工具 Android开发
解决bug:运行项目时报异常 “Can't create handler inside thread that has not called Looper.prepare()”
解决bug:运行项目时报异常 “Can't create handler inside thread that has not called Looper.prepare()”
1296 0
|
7月前
|
Python
“RuntimeError: main thread is not in main loop“的几种解决方案
“RuntimeError: main thread is not in main loop“的几种解决方案
|
7月前
|
Python
【ERROR】asyncio.run(main())报错:RuntimeError: Event loop is closed
【ERROR】asyncio.run(main())报错:RuntimeError: Event loop is closed
223 0
|
测试技术
winform关于catch Program.Main
winform关于catch Program.Main
|
Oracle Java 关系型数据库
JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread
JDK/JAVA Exception NSWindow drag regions should only be invalidated on the Main Thread
158 0
|
Python
may have been in progress in another thread when fork() was called.
may have been in progress in another thread when fork() was called.
147 0
may have been in progress in another thread when fork() was called.