xLua学习总结(四)---lua访问C#

1.在lua中调用unity日志打印hello world:

CS.UnityEngine.Debug.Log("hello world")

2.通过lua中创建一个unity中的GameObject

local newGameObj = CS.UnityEngine.GameObject("CreatByLua")
newGameObj.transform.position=CS.UnityEngine.Vector3(1,2,3)

注意:不需要使用new,按照上面方式,可以调用Unity中的方法,在场景中创建一个名为CreatByLua的游戏物体,并对其位置赋值。

猜你喜欢

转载自blog.csdn.net/l17768346260/article/details/103636096
今日推荐