All Projects → vimfung → Luascriptcore

vimfung / Luascriptcore

Licence: apache-2.0
一款简单易用的多平台Lua桥接器,目前支持在iOS、Mac OS X、Android以及Unity3D中使用,让原生环境与Lua无障碍沟通。

Programming Languages

c
50402 projects - #5 most used programming language
lua
6591 projects

Projects that are alternatives of or similar to Luascriptcore

Quick psd2ugui
parse psd file and auto generate ui prefab(解析psd文件,一键生成ugui面板)
Stars: ✭ 419 (-9.5%)
Mutual labels:  unity3d
Spaces Renamer
💻 Ability to rename desktop spaces on macOS 10.10+
Stars: ✭ 435 (-6.05%)
Mutual labels:  osx
Sipsorcery
A WebRTC, SIP and VoIP library for C# and .NET Core. Designed for real-time communications apps.
Stars: ✭ 449 (-3.02%)
Mutual labels:  unity3d
Unity Texture Packer
🔨 Utility to combine color channels from different textures into a single output.
Stars: ✭ 429 (-7.34%)
Mutual labels:  unity3d
Verticaldissolve
Procedural vertical dissolve shader. Highly customizable. Tweak edge color, noisiness & waviness, rim light, emission scrolling and more.
Stars: ✭ 434 (-6.26%)
Mutual labels:  unity3d
Actors.unity
🚀Actors is a framework empowering developers to make better games faster on Unity.
Stars: ✭ 437 (-5.62%)
Mutual labels:  unity3d
Redrunner
Red Runner, Awesome Platformer Game.
Stars: ✭ 414 (-10.58%)
Mutual labels:  unity3d
Reorderableinspector
Automatic reorderable lists for Unity game engine components
Stars: ✭ 455 (-1.73%)
Mutual labels:  unity3d
Skeletalgeometriceffects
Experiments on geometry shader instancing with skeletal animations
Stars: ✭ 436 (-5.83%)
Mutual labels:  unity3d
Ergo
The management of multiple apps running over different ports made easy
Stars: ✭ 452 (-2.38%)
Mutual labels:  osx
Qt Nice Frameless Window
Qt Frameless Window for both Windows and OS X, support Aero Snap, drop shadow on Windows, and support Native Style such as round corner, drop shadow on OS X. Based on QMainWindow.
Stars: ✭ 430 (-7.13%)
Mutual labels:  osx
Framework
Machine learning, computer vision, statistics and general scientific computing for .NET
Stars: ✭ 4,177 (+802.16%)
Mutual labels:  unity3d
Node Bluetooth Serial Port
Serial I/O over bluetooth for NodeJS
Stars: ✭ 444 (-4.1%)
Mutual labels:  osx
Dellxps15 9550 Osx
Tutorial for a full working Mac OS (10.11 up to 11.0) enviroment on the Dell XPS 15 (9550)
Stars: ✭ 428 (-7.56%)
Mutual labels:  osx
Volumecloud
Volume cloud for Unity3D
Stars: ✭ 453 (-2.16%)
Mutual labels:  unity3d
Phaser Ce Npm Webpack Typescript Starter Project
Project to get you started with your Phaser-CE (using the npm module) game using Typescript and Webpack for building! No hassle asset management, Google Web Font loader, live server, development vs distribution build pipeline, Electron packaging for desktop builds, and more...
Stars: ✭ 414 (-10.58%)
Mutual labels:  osx
Upmgitextension
This package extends the UI of Unity Package Manager (UPM) for the packages installed from git repository.
Stars: ✭ 438 (-5.4%)
Mutual labels:  unity3d
Unityurpunlitscreenspacedecalshader
Unity unlit screen space decal shader for URP. Just create a new material using this shader, then assign it to a new unity cube GameObject = DONE, now you have unlit decal working in URP
Stars: ✭ 455 (-1.73%)
Mutual labels:  unity3d
Github Matrix Screensaver
The GitHub Matrix Screensaver for Mac OSX
Stars: ✭ 453 (-2.16%)
Mutual labels:  osx
Miniengineao
SSAO image effect from Microsoft MiniEngine, ported to Unity.
Stars: ✭ 448 (-3.24%)
Mutual labels:  unity3d

功能&特点

LuaScriptCore旨在能够在多种平台上方便地使用Lua。其提供了与多种平台的功能交互,让开发者无须关心Lua与各个平台之间是实现交互的细节,只需要根据自己的业务需求,使用LuaScriptCore提供的方法,轻松简单地实现各种功能。如:

  • 原生代码调用Lua中的方法和变量,控制Lua的业务逻辑

如,Lua中有如下定义

url = "https://vimfung.github.io/LuaScriptCore/";

function printUrl(url)

  print (url);

end

在原生代码中可以如下面操作Lua变量和方法:

iOS/OSX

//获取变量
LSCValue *urlValue = [context getGlobalForName:@"url"];
NSLog(@"url = %@", [urlValue toString]);

//调用方法
[context callMethodWithName:"printUrl" arguments:@[urlValue]];

Android

//获取变量
LuaValue urlValue = context.getGlobal("url");
Log.d("LuaScriptCore", String.format("url = %s", urlValue.toString()));

//调用方法
context.callMethod("printUrl", new LuaValue[] {urlValue});

Unity3D

//获取变量
LuaValue urlValue = context.getGlobal ("url");
Debug.LogFormat ("url = {0}", urlValue.toString ());

//调用方法
context.callMethod("printUrl", new List<LuaValue>(new LuaValue[] {urlValue}));
  • Lua中调用原生提供的方法,让一些Lua无法处理或者耗时的处理交由原生方法实现

如,原生代码为Lua定义输出日志方法log:

iOS/OSX

[context registerMethodWithName:@"log" block:^LSCValue *(NSArray<LSCValue *> *arguments) {
       
  NSLog(@"%@", [arguments[0] toString]);
  return nil;
  
}];

Android

context.registerMethod("log", new LuaMethodHandler() {

  @Override
  public LuaValue onExecute(LuaValue[] arguments) {       
    Log.d("LuaScriptCore", arguments[0].toString());
    return null;
  }
  
});

Unity3D

LuaContext.currentContext.registerMethod("log", (List<LuaValue> arguments) => {

  Debug.Log(arguments[0].toString());
  return null;

});

在Lua中则可以调用该方法:

log("Hello World");
  • 原生代码定义类型直接映射到Lua中使用,让Lua更方便地实现面向对象的编程

原生代码有如下类型定义:

iOS

@interface LuaType : NSObject <LSCExportType>

// 定义属性和方法...

@end

Android

class LuaType implements LuaExportType
{
// 定义属性和方法...
}

Unity3D

class LuaType : LuaExportType 
{
// 定义属性和方法...
}

则可以在Lua中进行使用,如:

local obj = LuaType();
print (obj);

如何使用

iOS / OS X 平台

关于iOS/OS X平台下如何使用LuaScriptCore,请参考《iOS/OS X集成使用文档

Android 平台

关于Android平台下如何使用LuaScriptCore,请参考《Android集成使用文档

Unity3D

关于Unity3D下如何使用LuaScriptCore,请参考《Unity3D集成使用文档

注意

目前源码中不带有任何平台的Release库,在运行Sample时需要从Relases页签中下载最新版本的库并放入Sample项目后运行。

API文档

最近更新

Release 2.4.0 - 下载

更新内容:

  1. 新增线程执行功能,可以通过LuaContext的runThread方法将一个lua方法执行在不同的线程中。
  2. LuaValue新增setObject方法,允许直接为table对象设置和删除键值对,而不是通过返回值的方法进行调整。
  3. 新增LuaContext的脚本执行控制接口,可以通过LuaScriptController来强制中断脚本执行。
  4. iOS / OSX 平台下增加初始化上下文时传入配置接口,允许导出类方法名称时使用完整名称。
  5. 优化addSearchPath方法,可以加入lua文件以外的文件路径
  6. 优化Android和Unity3D下的抛出Lua异常操作
  7. 修复抛出异常时导致内存泄漏和程序死锁问题
  8. 修复iOS / OSX 平台下使用Swift的@objc导出类无法找到问题
  9. 修复Android平台下传递数组中包含导出类型对象时产生JNI栈溢出问题。
  10. 修复Android平台下,从原生层传入基础类型数组时无法转换到lua中使用问题。
  11. 修复Android平台下LuaValue无法识别传入byte[]类型问题。
  12. 修复Android平台下,对象方法传入float、int、long类型参数时无法识别问题。
  13. 修复Android平台下,对象方法返回值为float时无法识别问题。
  14. 修复Android平台下LuaTuple返回基础类型值不正确问题
  15. 修复Android平台下LuaTuple设置List类型为返回值时获取不到列表内容问题
  16. 修复Android平台下循环调用方法时导致崩溃问题
  17. 修复Android平台下创建类对象是内存泄漏问题
  18. 修复Unity3D下LuaValue转换为object时,如果数据为数组或者字典里面的元素没有解包问题。

更多更新历史

建议&支持

如问题请与我联系

QQ技术讨论群

赞助

打开支付宝扫一扫,给予我支持

打开支付宝扫一扫

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].