GithubHelp home page GithubHelp logo

owllyi / xlua Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tencent/xlua

1.0 0.0 1.0 27.03 MB

xLua is a lua programming solution for C# ( Unity, .Net, Mono) , it supports android, ios, windows, linux, osx, etc.

License: Other

C# 5.44% CMake 1.38% C 63.03% C++ 3.34% Makefile 0.77% HTML 16.38% CSS 0.19% Batchfile 0.36% Lua 8.73% Shell 0.09% Roff 0.24% Perl 0.05%

xlua's Introduction

license release PRs Welcome Build status

(English Documents Available)

C#下Lua编程支持

xLua为Unity、 .Net、 Mono等C#环境增加Lua脚本编程的能力,借助xLua,这些Lua代码可以方便的和C#相互调用。

xLua的突破

xLua在功能、性能、易用性都有不少突破,这几方面分别最具代表性的是:

  • 可以运行时把C#实现(方法,操作符,属性,事件等等)替换成lua实现;
  • 出色的GC优化,自定义struct,枚举在Lua和C#间传递无C# gc alloc;
  • 编辑器下无需生成代码,开发更轻量;

更详细的特性、平台支持介绍请看这里

安装

打开zip包,你会看到一个Assets目录,这目录就对应Unity工程的Assets目录,保持这目录结构放到你的Unity工程。

如果希望安装到其它目录,请看FAQ相关介绍。

文档

快速入门

一个完整的例子仅需3行代码:

安装好xLua,建一个MonoBehaviour拖到场景,在Start加入如下代码:

XLua.LuaEnv luaenv = new XLua.LuaEnv();
luaenv.DoString("CS.UnityEngine.Debug.Log('hello world')");
luaenv.Dispose();

1、DoString参数为string,可输入任意合法的Lua代码,本示例在lua里调用C#的UnityEngine.Debug.Log打印了个日志。

2、一个LuaEnv实例对应Lua虚拟机,出于开销的考虑,建议全局唯一。

C#主动调用lua也很简单,比如要调用lua的系统函数,推荐方式是:

  • 声明
[XLua.CSharpCallLua]
public delegate double LuaMax(double a, double b);
  • 绑定
var max = luaenv.Global.GetInPath<LuaMax>("math.max");
  • 调用
Debug.Log("max:" + max(32, 12));

建议绑定一次,重复使用。生成了代码的话,调用max是不产生gc alloc的。

热补丁

  • 侵入性小,老项目原有代码不做任何调整就可使用。
  • 运行时影响小,不打补丁基本和原有程序一样。
  • 出问题了可以用Lua来打补丁,这时才会走到lua代码逻辑;

这里是使用指南。

更多示例

技术支持

一群:612705778 (已满)

二群:703073338 (已满)

三群:811246782

入群的问题:有问题该先从哪找答案

回答:FAQ

平时也要谨记这答案,90%以上问题都可以在FAQ里头找到答案。这些问题就别在群刷屏了。

xlua's People

Contributors

3wz avatar bigoyayubi avatar chaosddp avatar chexiongsheng avatar domain avatar dotlive avatar ezhex1991 avatar forsakenyang avatar hsl4125 avatar ineversleeeeep avatar jayatubi avatar lindaluo1113 avatar magicqy avatar owllyi avatar pkujhd avatar ps5mh avatar pureivan avatar rebelmx4 avatar rockhills avatar tomoya0320 avatar vkensou avatar waizui avatar wangyongxina avatar xiangyuan avatar xpol avatar xuyanghuang-tencent avatar yangguosdxl avatar yesbaba avatar zhaoboqiang avatar zxsean avatar

Stargazers

 avatar

Forkers

lanyantao

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.