johnsoncodehk 发表于 2021-8-14 16:41

xlua-使用xlua内置的加载器加载lua文件

using System.Collections;using System.Collections.Generic;using UnityEngine;using XLua;/*
* Author:W
* 使用xlua内置的加载器加载lua文件
*/publicclassLuaLoaderNative:MonoBehaviour{privateLuaEnv luaEnv;// Start is called before the first frame updatevoidStart(){
      luaEnv =newLuaEnv();//require关键字:表示使用内置的加载器加载Resources文件夹下HelloUnity.lua文件,并执行
      luaEnv.DoString("require 'HelloUnity'");}privatevoidOnDestroy(){
      luaEnv.Dispose();}}运行结果截图如下:

页: [1]
查看完整版本: xlua-使用xlua内置的加载器加载lua文件