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