框架-LuaFramework(待写)

2018-09-03  本文已影响0人  叫我颜先生

简介

从接触到Lua到现在差不多半年了,但对于Lua框架很多地方并不知道是如何实现的,只知道一直在写着游戏逻辑的Lua脚本。最近开始系统了解学习一下,不断扩充,充实自己。

刚开始总是对这几个名词弄混,正好整理一下

结构

完整框架基本是这样的:

流程

流程.png

自定义API

  1. 编写C#类(方法是静态的)

    public class Test {
    
     public static void Log()
        {
            Debug.LogError("----------");
        }
    }
    
  2. customsetting中添加类类型

    _GT(typeof(Test))

  3. 重新生成wrap文件,在新生成的TestWrap中有对应生成的Log方法

  4. Lua中调用Test.Log()

    此处调用是用‘ . ’

报错解决

  1. Create not wrap ulua type…

    这不是错误,警告你当前类没有生成wrap,用的反射,为了效率请将该类注册wrap

  2. luaopen_pack, referenced from: "_lua_tocbuffer"

    去掉LuaDLL.cs中报错函数声明,及其相关报错代码

  3. Type UnityEngine.xxx does not contain a definition for xxx and no extension method xxx of type UnityEngine.xxx could be found (are you missing a using directive or an assembly reference

    因为unity不同平台版本api各不相同,因此不是特别统一,遇到此问题直接删除错误代码即可

小结

参考

http://doc.ulua.org/article/ngui/simpleframework_base1.html

https://blog.csdn.net/Momo_Da/article/details/52857219

上一篇 下一篇

猜你喜欢

热点阅读