Search Unity

uLua - Lua for Unity

Discussion in 'Assets and Asset Store' started by topherr, Jan 7, 2014.

  1. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    $ulualogo.jpg

    uLua Asset Store Page

    Lua + LuaJIT + LuaInterface

    Supported Platforms: iOS, Android, Windows, Mac, Linux

    Want Lua support in your project? This package comes with everything you need, ready to go on all of the major platforms.

    Features:
    - Lua 5.1.4 for all supported platforms
    - Amazing Lua performance thanks to LuaJIT
    - LuaInterface based for powerful C# integration
    - Additional LuaInterface features: Lua Coroutines, Unity error handling, more Lua API functions
    - Prebuilt Lua plugin


    See readme for usage.
    ulua-support@polynationgames.com
    E-mail us for support if anything is not working. We'll try our best to help!

    We can add more examples on request.
     
  2. Sinfritz

    Sinfritz

    Joined:
    Nov 18, 2012
    Posts:
    72
    Nice! I remember there being another plugin a while back when I was looking into this (kopilua). I suppose this solves most of the issues surrounding integration. I guess you took the dll route (hence LuaInterface) so definitely can't use this for browser runtime.

    Also one of the main reason I took interest in using Lua in Unity is to allow scripting during runtime and be able to execute it. I'm guessing this plugin allows for that?
     
  3. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Great plugin,

    Does this work on Web Player ?

    Cheers.
     
  4. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Cool, been looking for a nice Unity-Lua integration, will probably pick this up later : )
     
  5. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    The LuaInterface DLL works fine in browsers/web player. The Dialogue System for Unity uses George Foot's KopiLuaInterface, which you can see in action in all the browser demo scenes here: http://www.pixelcrushers.com/dialogue-system-demos/

    I don't see why uLua would be any different.
     
  6. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    You might need to check Unity's usage guidelines for their logo, not sure you're allowed to make it blue etc.
     
  7. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Very cool, are you 100% sure about this?
     
  8. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Since Unity accepted this asset on the store im pretty sure it ok : )
     
  9. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @topherr

    "Unity does not support Native Plugins for the WebPlayer, so uLua will never work until they change that policy due to using a C library for the Lua runtime."

    Is there a way to make this package work with WebPlayer like KopiLuaInterface from George Foot ? Pixel Crusher got KopiLuaInterface working in the Dialogue System.

    Cheers.
     
  10. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    You just need to play the demos to see proof. ;-) It uses KopiLua, which is a pure C# implementation of Lua, so no issues with C libraries.

    Sorry, I didn't mean to sidetrack this thread. Since virror wrote "LuaInterface based for powerful C# integration," I figured uLua would be the same, which is the only reason why I mentioned it.
     
  11. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I spoke to topherr and he's using a C-runtime (probably of the JIT). It's also probably faster than the C# runtime version (not sure how much faster).

    Perhaps Topherr could provide more info.

    Cheers.
     
  12. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @TonyLi,

    In the case that uLua is much faster than KopiLua, would it be possible for your Dialogue System to add support for uLua in addition to KopiLua.
     
  13. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    I'm kind of interested in a Lua add-on for unity, but there's not a lot of info about this and what it's capable of. The lack of replies from the author is a bit discerning. :(
     
  14. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    I've been emailing the author and he's answering right away. Perhaps he's not getting notifications from the forum.. I did inform him that people are using the forum.


    @Virror,

    Videos and example documentations would really help potential buyers appreciate the power and flexibility of uLua.

    Cheers.
     
  15. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I haven't done any benchmarking, but I can't imagine that the C implementation would be significantly faster than the C# implementation in most cases. They're both written in native, compiled languages. I'd be curious to see if there was any performance difference in benchmarks. Even if there were, for the Dialogue System it wouldn't make any difference in performance for the player because of where Lua is used in it. However, if you really wanted to swap out KopiLuaInterface, as I mentioned earlier on the Dialogue System thread there's a bridge class between the Dialogue System and whatever Lua implementation is underneath. You could always replace that bridge class with one that references a different Lua implementation.
     
  16. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    Hey guys,

    I got rocki's e-mail and it seems my notifications weren't working, but I'll keep an eye on it and get some answers for people.

    Additionally currently looking into WP8 version, and C# interpreters to cover the WebPlayer but it will lose the performance of LuaJIT.
     
    Last edited: Feb 6, 2014
  17. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    Yes it does, additionally it provides a means to DLC game logic (missions, scripted abilities etc) which you otherwise cannot do in Unity at the moment.
     
  18. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    What info would you like? Generally I'm also working on our game that we put uLua together for, so I've not had time to put up a website.
     
  19. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    I can't comment on existing C# implementations at the moment but uLua uses LuaJIT which when compared to the standard Lua runtime has -huge- performance improvements.

    Check here for benchmarks comparing LuaJIT with
    http://luajit.org/performance_x86.html
     
  20. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    Sorry, the JIT support slipped my mind when I was replying. Yes, I won't argue at all that this will make it faster than KopiLuaInterface. For the purposes of the Dialogue System, it won't make any noticeable difference, but I can imagine uses where it would make a big difference.
     
  21. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
    It's simply that I'm not sure what you can do with it, how it ties into unity, how to use it, etc. I'm sure you have that covered in the documentation, but since the documentation is not public, it's hard to judge before I make a purchase.
     
  22. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Some working code examples of how uLua is integrated with Unity in a game scenario would be really nice to have.
     
  23. topherr

    topherr

    Joined:
    Jun 1, 2013
    Posts:
    25
    I'm going to see about getting the documentation public first, then look into covering some examples of uLua usage in a game scenario.

    Not sure how long this will take, as we're working on a game as well. Initially I only imagined uLua being used by people already in need of Lua in their game and aware of where they will use it. It seems people are interested in how they might use it, curious at least, so I can see the need to explain uLua much more.

    Suggestions on what people would like to see would be appreciated! :)
     
  24. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,694
    I'm guessing that many people would like to see examples that allow the player to write and run scripts during runtime. If you're only writing code at design time, you might as well use the built-in C#, UnityScript, or Boo.
     
  25. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Some ideas:

    1. Use Lua to create mini games that can be dynamically loaded into unity.
    2. Use Lua to create game UI's, create events and handle events for the generated GUI.
    3. Use Lua to to create and communicate with Unity's GameObjects, Components, Scripts, etc.

    Edit: This is what I asked in Dialogue System forum, I thought I would also ask it here.

    I'm wondering if it's possible to do all of the following in Lua without having to writing any preparatory C# code.

    1. Define an onPowerUp event.
    2. Create a button that fires the onPowerUp event.
    2. Create a cube using Lua.
    3. Create a listener function
    4. Attach listener to cube.

    So when the user clicks the button, the onPowerUp event fires, the cube then fires the listener function.

    Edit: I found this posting
    hegallis.blogspot.in/2009/02/lua-in-net.html

    Is there a way to define event delegates so that they can be totally generic so that lua can create its own custom events.
     
    Last edited: Feb 11, 2014
  26. Doddler

    Doddler

    Joined:
    Jul 12, 2011
    Posts:
    269
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @topherr

    Is there a trial version that we can test out the package.

    Would like to know that it works well on the various supported platforms.

    Cheers.
     
  28. topameng

    topameng

    Joined:
    Feb 18, 2014
    Posts:
    3
    can't load file complie by luajit
     
  29. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    So, how do i use this? : p
    How do i aff my own stuff to this, as an example if i want to have lua functions for creating GUI or for calling my own C# functions?
     
  30. Siney

    Siney

    Joined:
    Dec 22, 2014
    Posts:
    5
    fastest lua binding for unity3d, 10x-100x faster than ulua.

    you can use slua https://github.com/pangweiwei/slua,

    feature:

    static code generating, no reflection, no extra gc alloc, very fast

    above 90% UnityEngine interface exported ( remove flash, platform dependented interface )

    100% UnityEngine.UI interface ( require Unity4.6+ )

    support UnityEvent/UnityAction for event callback via lua function

    support delegate via lua function

    support custom class exported

    export enum as integer

    return array as lua table

    using raw lua 5.3, can be replaced with luajit/lua5.1.
     
  31. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Looks cool! : )
     
  32. yoshisan

    yoshisan

    Joined:
    May 25, 2015
    Posts:
    6
    Please support OSX 64bit !
     
  33. ThePC007

    ThePC007

    Joined:
    Aug 8, 2014
    Posts:
    3
    How come uLua has been deprecated from the Asset Store? Was anything wrong with it?