多线程调用的脚本在Unity3d [英] Multithreaded Script invocation in Unity3d

查看:210
本文介绍了多线程调用的脚本在Unity3d的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Unity3d中实现多线程脚本执行,但似乎没有由Unity库提供的方式,我们必须使用Mono提供的System.Threading。但是他们提到Unity脚本不是线程安全的。

I was trying to implement multithreaded script execution in Unity3d, but it seems that the there is no way provided by Unity libraries and we have to use System.Threading provided by Mono. But they have mentioned that Unity Scripting is not thread safe.

我可以使用System.threading或其他独立于平台的API在Unity3D中安全高效地实现多线程吗?
也如何确保脚本并行运行?

Can i implement Multithreading safely and efficiently in Unity3D using System.threading or other Platform independent API ? Also how can i make sure that the scripts are running in parallel ?

一个例子或链接将非常感谢。

An example or a link would be highly appreciated.

回应

推荐答案

我需要为iOS应用程式使用线程我从来没有找到一个方法来做这样的在Unity。但是你可以编写一个使用线程的插件。在我的应用程序中,我需要线程来计时一个音乐应用程序,所以我写了一个音频插件库使用核心音频在Xcode,你可以做所有你想要的线程。但是管理Unity和插件之间的同步是很痛苦的。

I needed threading for an iOS application, unfortunately I never found a way to do such in Unity. But you can write a plugin that uses threading. In my application I needed threading for timing a music application, so I wrote an audio plugin library that uses core-audio in xcode and you can do all the threading you want there. But managing syncing between Unity and the plugin is quite painful.

这篇关于多线程调用的脚本在Unity3d的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆