1.将自定义脚本加入WrapFile中,如下图自定义Test脚本
2.在Unity面板(已经导入ulua_v1.25插件)中点击Lua->Gen Lua Wrap Files即可在ulua->source->luaWrap中生成TestWrap脚本
3.Test脚本如下
using System.Collections.Generic;
using UnityEngine;
public class Test
{
void Start()
{
}
public void Show()
{
Debug.Log("show");
}
public static void ShowMess()
{
Debug.Log("StaticShow");
}
void Update()
{
}
}
4.挂载脚本
using System;
using System.Collections.Generic;
using UnityEngine;
using LuaInterface;
class LuaCShapeTest : MonoBehaviour
{
string script = @" test = Test(); test:Show(); Test.ShowMess(); ";
void Start()
{
LuaScriptMgr mgr = new LuaScriptMgr();
mgr.Start();
mgr.DoString(script);
}
// Update is called once per frame
void Update()
{
}
}
|
请发表评论