版权声明:本文为博主原创文章,未经博主允许不得转载。博客地址:http://blog.csdn.net/yy763496668 https://blog.csdn.net/yy763496668/article/details/78918180
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LuaInterface;
public class UnityCallLua : MonoBehaviour {
string str = @"
luanet.load_assembly('UnityEngine')
PrimitiveType = luanet.import_type('UnityEngine.PrimitiveType')
GameObject = luanet.import_type('UnityEngine.GameObject')
Debug = luanet.import_type('UnityEngine.Debug')
--Debug.Log('helloworld')
--uLua创建一个Cube
GameObject.CreatePrimitive(PrimitiveType.Cube)
obj = GameObject.Find('Main Camera')
Debug.Log(obj.name)
";
void Start () {
LuaScriptMgr mgr = new LuaScriptMgr();
mgr.Start();
mgr.lua.DoString(str);
}
}