CS.UnityEngine静态方法访问unity虚拟机
创建游戏物体
lua
复制代码
CS.UnityEngine.GameObject('new by lua');
静态属性
lua
复制代码
CS.UnityEngine.GameObject('new by lua'); -- 创建
local camera = CS.UnityEngine.GameObject.Find('Main Camera'); --查找
camera.name = 'Renamed by Lua';
访问组件
lua
复制代码
local gameObject = CS.UnityEngine.GameObject;
local camera = gameObject.Find('Main Camera'); --查找
camera.name = 'Renamed by Lua'; --修改
两种形式 . & :
lua
复制代码
local cameraCom = camera:GetComponent("Camera")
local cameraCom = camera.GetComponent(camera,"Camera")
--销毁
gameObject.Destory(cameraCom)