惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Project Zero
Project Zero
B
Blog RSS Feed
爱范儿
爱范儿
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
阮一峰的网络日志
阮一峰的网络日志
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
D
Docker
B
Blog
大猫的无限游戏
大猫的无限游戏
V
Vulnerabilities – Threatpost
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
博客园 - 【当耐特】
IT之家
IT之家
云风的 BLOG
云风的 BLOG
L
Lohrmann on Cybersecurity
V
V2EX
Latest news
Latest news
S
Secure Thoughts
C
Check Point Blog
N
Netflix TechBlog - Medium
N
News | PayPal Newsroom
C
Cybersecurity and Infrastructure Security Agency CISA
The Register - Security
The Register - Security
The Cloudflare Blog
博客园_首页
博客园 - 三生石上(FineUI控件)
L
LINUX DO - 最新话题
W
WeLiveSecurity
G
GRAHAM CLULEY
量子位
T
The Exploit Database - CXSecurity.com
Security Latest
Security Latest
C
Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
GbyAI
GbyAI
A
Arctic Wolf
Attack and Defense Labs
Attack and Defense Labs
博客园 - 叶小钗
SecWiki News
SecWiki News
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
S
Security @ Cisco Blogs
小众软件
小众软件
N
News and Events Feed by Topic
WordPress大学
WordPress大学

博客园 - Stanley.Luo

CentOS 7+nginx+PHP+php-fpm Linux 的系统目录介绍 C++与Java,C#的异同(一):值,地址,引用 3Dmax 创建物体 3DMax 物体选择方法 3DMax 常用快捷键 HTC Vive 与Leap Motion 出现位置错误的问题 Groovy与Gradle在Android中的应用 VR的UI、UX设计原则 为什么带网格(mesh)的模型添加了刚体Rigidbody和MeshCollider,还是会从地板穿过去? Mecanim动画模型规范 Mecanim动画系统 制作流程 HTC Vive 体验的折腾经历 OpenGLES 2.0 可编程渲染管线 【VR视频播放】解决Unity模型贴图反转的问题 Lua语言的特别之处 Unity3D 的摄像机 iptables 的使用 CentOS安装Nginx
Loom工具类:Unity3D巧妙处理多线程
Stanley.Luo · 2017-01-02 · via 博客园 - Stanley.Luo

Loom代码不多,只有168行, 然而却具备了子线程运行Action, 子线程与主线程交互的能力!

public static Thread RunAsync(Action a)

public static void QueueOnMainThread(Action action)

public static void QueueOnMainThread(Action action, float time)

首先Loom类继承自MonoBehaviour,第一次使用静态的Loom.Current时,就会判断,是否初始化(其实就是将Loom 挂载到 一个自己创建的GameObject上),这样,QueueOnMainThread放进来的action就可以在每一帧回调的Update方法进行action调用。

RunAsync用线程池,运行在子线程中。 使用的时候, 当子线程的工作完成后, 可以在后面加一句Loom.QueueOnMainThread()实现线程切换!