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();
}
}
運行結果截圖如下