xlua-lua代碼中調用C#的API

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



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

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