–导入unity引擎
local GameObject = CS.UnityEngine.GameObject;
local Vector3 = CS.UnityEngine.Vector3;
local Input = CS.UnityEngine.Input;
Test = {};
local this = Test;
this.Awake = function()
print(“awake…”);
end
this.Start = function()
–[[
调用C#中的对像方法时,注意:
静态方法用 类名.方法(),
set,get方法,也用 对象名.方法名
普通方法用 对象名:方法名()
]]
speed=5;
obj = CS.UnityEngine.GameObject.CreatePrimitive(3);–加载物体
obj.name=“111”–重命名
obj.transform.localScale = Vector3.one * 2;–设置大小
print(“start 调用了”);
end
this.Update = function()
–print(“update…”);
local h = Input.GetAxis(“Horizontal”)
local v = Input.GetAxis(“Vertical”)
–设置位置方法
–obj.transform.localPosition={x = 0, y = 100, z = 0};
local x1 = obj.transform.position.x + h
local y1 = obj.transform.position.z + v
obj.transform.position={x=x1+h,y=0 , z = y1+v};
end