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


相关文章
|
6月前
|
Python
python RuntimeError: main thread is not in main loop
python RuntimeError: main thread is not in main loop
179 1
|
6月前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
127 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 )(一)
857 0
【错误记录】Flutter 插件报错 ( Methods marked with @UiThread must be executed on the main thread. | 更新最新 SDK )(一)
|
开发工具 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()”
1213 0
|
5月前
|
Python
“RuntimeError: main thread is not in main loop“的几种解决方案
“RuntimeError: main thread is not in main loop“的几种解决方案
|
测试技术
winform关于catch Program.Main
winform关于catch Program.Main
|
Dart 安全
Flutter开发Cannot run with sound null safety报错
Flutter开发Cannot run with sound null safety报错
|
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
150 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.
140 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
208 0