acecase 发表于 2021-8-14 12:54

xlua-lua代码中调用C#的API

using System.Collections;using System.Collections.Generic;using UnityEngine;using XLua;/*
* Author:W
* Lua代码中调用C#的API
*/publicclassLuaUseCSCode:MonoBehaviour{privateLuaEnv luaEnv;// Start is called before the first frame updatevoidStart(){
      luaEnv =newLuaEnv();//CS前缀+C#代码命名空间+C#类+C# API
      luaEnv.DoString("CS.UnityEngine.Debug.Log('Hello Lua!')");}privatevoidOnDestroy(){if(luaEnv!=null)
          luaEnv.Dispose();}}运行结果截图如下

页: [1]
查看完整版本: xlua-lua代码中调用C#的API