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(() =>{
//你的代码});


相关文章
|
9月前
|
Python
python RuntimeError: main thread is not in main loop
python RuntimeError: main thread is not in main loop
209 1
|
9月前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
191 1
已解决 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'.异常错误,已解决
677 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()”
1304 0
|
8月前
|
Python
“RuntimeError: main thread is not in main loop“的几种解决方案
“RuntimeError: main thread is not in main loop“的几种解决方案
|
8月前
|
Python
【ERROR】asyncio.run(main())报错:RuntimeError: Event loop is closed
【ERROR】asyncio.run(main())报错:RuntimeError: Event loop is closed
243 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
162 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.
152 0
may have been in progress in another thread when fork() was called.
|
Java Linux
Thread start 源码揭秘
Thread start 源码揭秘 public synchronized void start() { /** * This method is not invoked for the main method thread or "system" * group threads created/set up by the VM. Any new functionality added * to this method in the future may have to also be added to the VM. * * A ze
220 0