Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is possible to use lua code in Unity3D

Tags:

.net

unity3d

lua

We need to use some specific library written in Lua in unity application.
Is there any possible way aside from complete rewriting it in C#/JS?

like image 564
Vlad Fedin Avatar asked Jun 07 '12 22:06

Vlad Fedin


1 Answers

If you're targeting the web player, no. Web player builds run in a sandbox and cannot load external code, so with the possible exception of writing a Lua interpreter in C# (!), you're out of luck.

If you're targeting a desktop build or mobile device, then you can include external plugins and call out to them through scripts. This means you can import Lua and tell it to run your Lua script(s).

However, this may still be more trouble than it's worth, since you'll have to load and initialize the Lua runtime yourself, and therefore you might be better off just rewriting the code.

Note that for desktop platforms, a Pro license is required. For mobile platforms (iOS/Android), you may need to jump through some hoops to actually have your Lua script files available to load into the Lua runtime.

like image 106
Michael Madsen Avatar answered Nov 01 '22 17:11

Michael Madsen