xlua-Unity中執行lua代碼

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();
    }

}

運行結果截圖:
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章