• Unity热更新03-C#调用XLua-04-C#调用Lua全局变量


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    
    public class Lesson4_CallVariable : MonoBehaviour
    {
        void Start()
        {
            LuaMgr.GetInstance().Init();
    
            LuaMgr.GetInstance().DoLuaFile("Main");
    
            //int local = LuaMgr.GetInstance().Global.Get<int>("testLocal");
            //Debug.Log("testLocal:" + local);
    
            //使用lua解析器luaenv中的 Global属性 
            int i = LuaMgr.GetInstance().Global.Get<int>("testNumber");
            Debug.Log("testNumber:" + i);
            i = 10;
            //改值
            LuaMgr.GetInstance().Global.Set("testNumber", 55);
            //值拷贝 不会影响原来Lua中的值
            int i2 = LuaMgr.GetInstance().Global.Get<int>("testNumber");
            Debug.Log("testNumber_i2:" + i2);
    
            bool b = LuaMgr.GetInstance().Global.Get<bool>("testBool");
            Debug.Log("testBool:" + b);
    
            float f = LuaMgr.GetInstance().Global.Get<float>("testFloat");
            Debug.Log("testFloat:" + f);
    
            double d = LuaMgr.GetInstance().Global.Get<double>("testFloat");
            Debug.Log("testFloat_double:" + d);
    
            string s = LuaMgr.GetInstance().Global.Get<string>("testString");
            Debug.Log("testString:" + s);
        }
    
    }
    
    
  • 相关阅读:
    iuplua test failure
    lua C++ wrapper
    lua
    Redux系列01:从一个简单例子了解action、store、reducer
    Meteor入门介绍
    Express入门介绍vs实例讲解
    React半科普文
    Express模版引擎hbs备忘
    Gulp:插件编写入门
    gulp.src()内部实现探究
  • 原文地址:https://www.cnblogs.com/unitysir/p/13890939.html
Copyright © 2020-2023  润新知