Skip to content

yanghuan/CSharpLuaForUnity

Repository files navigation

CSharpLuaForUnity

CSharpLuaForUnity尝试使用CSharp.lua将Unity工程中的C#脚本编译至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所引用到

交流讨论

致谢

相关工程

About

CSharp.lua的Unity适配,可将Unity工程中的C#代码编译至Lua

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy