UnityXLua(六)Lua访问C#函数重载C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using XLua;
using System.IO;
using System.Text;
using UnityEngine.UI;
public class TestXLua : MonoBehaviour
{
LuaEnv lua;
void Start()
{
lua = new LuaEnv();
//加载Lua
lua.AddLoader(LoadLua);
lua.DoString("require 'TestLua'");
}
byte[] LoadLua(ref string file)
unity 教程
{
Debug.Log(file);
string slua = File.ReadAllText(Application.dataPath + "/Lua/" + file + ".lua");
byte[] bytes = new UTF8Encoding().GetBytes(slua);
return bytes;
}
void OnDestroy()
{
lua.Dispose();
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player
{
public void PFunction()
{
Debug.Log("PFunction:");
}
public void PFunction(int i,float f)
{
Debug.Log("PFunction:" + i + "/" + f);
}
public void PFunction(int i, string s)
{
Debug.Log("PFunction:" + i + "/" + s);
}
}
Lua
player = CS.Player()
player:PFunction() player:PFunction(12,12.6) player:PFunction(24,"aaa")

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。