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

推荐订阅源

D
DataBreaches.Net
Engineering at Meta
Engineering at Meta
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
H
Hackread – Cybersecurity News, Data Breaches, AI and More
F
Fortinet All Blogs
T
Threat Research - Cisco Blogs
B
Blog
K
Kaspersky official blog
Cisco Talos Blog
Cisco Talos Blog
T
The Exploit Database - CXSecurity.com
U
Unit 42
NISL@THU
NISL@THU
D
Docker
Vercel News
Vercel News
C
Check Point Blog
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
C
CERT Recently Published Vulnerability Notes
J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
Latest news
Latest news
Martin Fowler
Martin Fowler
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
Know Your Adversary
Know Your Adversary
A
Arctic Wolf
L
LINUX DO - 热门话题
IT之家
IT之家
SecWiki News
SecWiki News
博客园 - 【当耐特】
Schneier on Security
Schneier on Security
C
Cybersecurity and Infrastructure Security Agency CISA
The Last Watchdog
The Last Watchdog
S
Secure Thoughts
P
Proofpoint News Feed
N
News and Events Feed by Topic
S
Security @ Cisco Blogs
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
罗磊的独立博客
C
Cyber Attacks, Cyber Crime and Cyber Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Cloudbric
Cloudbric
O
OpenAI News
V
V2EX
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC

博客园 - 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()实现线程切换!