小结

来源:互联网 发布:校园打铃软件 编辑:程序博客网 时间:2024/05/23 17:03
Transform:
 
场景中的每一个物体都有一个Transform。用于储存并操控物体的位置(position)、旋转(rotate)和缩放(scale)。
transform.Translate(Vector3.forward);    物体的位置移动。
transform.Rotate(Vector3.forward);  表示在z轴上的旋转。
transform.localscale+=Vector3.forward;    表示在z轴上的增长。
 
 
Input:输入
 

键盘输入:(可以用户自定义)

Input.GetAxis 获取轴

获取轴中包括水平轴(Horizontal);垂直轴(Vertical);

Input.GetButton 获取按钮
Input.GetButtonUp 获取按钮弹起
Input.GetKey 获取键
Input.GetKeyDown 获取键按下
Input.GetKeyUp 获取键弹起

 

鼠标输入:

Input.GetMouseButton 获取鼠标按钮
Input.GetMouseButtonDown 获取鼠标按按按下。 Input.GetMouseButtonUp 获取鼠标按钮弹起
 
 
GameObject:

是Unity场景里面所有实体的基类.

 

GameObject.CreatePrimitive 创建基本物体
GameObject.Find 查找 GameObject.FindWithTag 查找标签
GameObject.Destory 销毁游戏对象
 
 
 
 
克隆对象 :

  gameobject.instrantiate(cube)

    示例:   gameobject  obj= (gameobject)intstantiate(cube)

 
 
 
Time 时间
time
The time this frame has started (Read Only). This is the time in seconds since the start of the game.
从游戏开始到到现在所用的时间(只读)。
 
deltaTime
The time in seconds it took to complete the last frame (Read Only).
以秒计算,完成最后一帧的时间(只读)。
 
 
SendMessage 消息的传递
 
gameobject.sendmessage向自身的脚本发送信息

broadmessage向自身及子脚本发送消息

sendmessageupward向自身及父物体发送脚本   

 
 
 
Random 随机

 

Range

Returns a random float number between and min [inclusive] and max [inclusive] (Read Only).
返回一个随机浮点数,在min(包含)和max(排除)之间。(只读)

示例:int   q=random.Range(0,123);

 

更多精彩内容请到:http://www.gopedu.com/


0 0
原创粉丝点击