zoukankan      html  css  js  c++  java
  • Unity热更新03-C#调用XLua-07-Lua表映射到C#接口

    using DSFramework;
    using UnityEngine;
    using UnityEngine.Events;
    using XLua;
    
    //接口不允许有成员变量
    //可以使用属性来接收
    [CSharpCallLua]
    public interface ILuaCallInterface {
        int testInt { get; set; }
        bool testBool { get; set; }
        float testFloat { get; set; }
        string testString { get; set; }
        UnityAction testFun { get; set; }
    }
    
    public class Lession8_LuaInterface : MonoBehaviour {
        private void Start() {
            DSLuaMgr.Instance.DoLuaFile("Main");
            ILuaCallInterface luaCallInterface = DSLuaMgr.Instance.Global.Get<ILuaCallInterface>("testClass");
            Debug.Log(luaCallInterface.testInt);
            Debug.Log(luaCallInterface.testBool);
            Debug.Log(luaCallInterface.testFloat);
            Debug.Log(luaCallInterface.testString);
            luaCallInterface.testFun();
            
            //接口拷贝 是引用拷贝 改了值 lua表中的值也变了
            luaCallInterface.testInt = 10000;
            ILuaCallInterface obj2 = DSLuaMgr.Instance.Global.Get<ILuaCallInterface>("testClas");
            Debug.Log(obj2.testInt);
        }
    }
    
  • 相关阅读:
    R-FCN、SSD、YOLO2、faster-rcnn和labelImg实验笔记
    yolov3的anchor机制与损失函数详解
    CV资料推荐
    测试用例设计方法总结
    测试需求分析
    bug生命周期
    linux命令一
    linux 命令二
    linux 命令三
    mysql数据库和禅道安装
  • 原文地址:https://www.cnblogs.com/unitysir/p/13891007.html
Copyright © 2011-2022 走看看