using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;//引入命名空間
/*
* Author:W
* 執行Lua代碼
*
*/
public class LuaRunTest : MonoBehaviour
{
private LuaEnv luaEnv;
// Start is called before the first frame update
void Start()
{
//創建lua運行環境實例
luaEnv = new LuaEnv();
//執行lua代碼
luaEnv.DoString("print('Hello Unity!')");
}
private void OnDestroy()
{
//釋放lua環境實例
luaEnv.Dispose();
}
}
運行結果截圖: