using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using XLua;
//和类映射一样只不过
//接口中不允许有成员变量,要用属性来接受
//要加一个CSharpCallLua特性标识
//接口拷贝是引用拷贝
[CSharpCallLua]
public interface ICsharpCallInterface
{
int testInt { get; set; }
bool testBool { get; set; }
float testFloat { get; set; }
string testString { get; set; }
UnityAction testFun { get; set; }
}
public class Lesson8_CallInterface : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
LuaMgr.GetInstance().Init();
LuaMgr.GetInstance().DoLuaFile("Main");
ICsharpCallInterface obj = LuaMgr.GetInstance().Global.Get<ICsharpCallInterface>("testClass");
Debug.Log(obj.testInt);
obj.testFun();
}
// Update is called once per frame
void Update()
{
}
}
C#调用lua映射接口
最新推荐文章于 2024-10-03 18:02:07 发布