Giter Club home page Giter Club logo

csharpluaforunity's Introduction

CSharpLuaForUnity

CSharpLuaForUnity尝试使用CSharp.lua将Unity工程中的C#脚本编译至Lua,以使其可用C#进行高效的开发,但是也能用Lua完成热更新,也已经开始在部分新项目中被采用。

依赖说明

  • 使用tolua版本作为Lua支持环境
  • 使用CSharp.lua来将C#代码转换至Lua

如何使用

  • 在Unity编辑器环境下,会新增菜单项'CSharpLua',子菜单'Compile'可将工程目录Compiled下的C#代码编译成Lua代码放置到Assets/Lua/Compiled目录,子菜单'Switch to XXX'可在运行C#代码还是编译后的Lua代码中切换。设想的是实际开发中一直使用C#代码开发和调试,需要真机发布时,才编译到Lua代码。
  • Examples目录下有一个简易的列子,可直接运行。可以看出能够支持在预设中挂载自定义的C#脚本,在运行Lua代码时,预设会被动态适配处理,具体实现可见代码。因而在打包时也需要对存在挂载了自定义C#脚本的的预设做相同的处理。

项目结构

使用了assembly definition files额外定义了一些程序集工程,依赖顺序如下。

Assembly-CSharp.dll --------> Compiled.dll --------> Bridge.dll --------> Base.dll

  • Compiled 此工程中的代码可编译至Lua,需要热更新的代码放到这个工程中
  • Bridge 可被Compiled引用的代码,需要Wrap到Lua的环境中
  • Base 可被Bridge引用的代码,但是不需要被Compiled所引用到

交流讨论

致谢

相关工程

也可以考虑使用ILRuntime完成类似的需求 https://github.com/Ourpalm/ILRuntime

csharpluaforunity's People

Contributors

mybios avatar yanghuan avatar zjkzxy avatar

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.