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


相关文章
|
22天前
|
Python
python RuntimeError: main thread is not in main loop
python RuntimeError: main thread is not in main loop
92 1
|
22天前
|
NoSQL 编译器 API
关于thread使用的错误:pure virtual method called terminate called without an active exception
关于thread使用的错误:pure virtual method called terminate called without an active exception
16 1
|
10月前
已解决 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'.异常错误,已解决
165 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()”
918 0
|
8月前
|
测试技术
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
127 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.
118 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
169 0
|
图形学 Android开发
Unity3d:Exception: JNI: Init'd AndroidJavaClass with null ptr!
Unity3d 错误:Exception: JNI: Init'd AndroidJavaClass with null ptr! 解决:需要运行在安卓真机上。
2102 0
Can't create handler inside thread that has not called Looper.prepare()
版权声明:本文为博主原创文章,转载请标明出处。 https://blog.csdn.net/chaoyu168/article/details/52163029 最近做项目时出现个问题。
1180 0

热门文章

最新文章