2015-7-4

来源:互联网 发布:语音变声器软件 编辑:程序博客网 时间:2024/06/09 22:14
using UnityEngine;using System.Collections;public class sjt2 : MonoBehaviour {// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {transform.position += new Vector3 (1, 0, 0) * Time.deltaTime;// 物体一直朝向x轴移动}}
</pre><pre name="code" class="cpp"><pre name="code" class="cpp">using UnityEngine;using System.Collections;public class NewBehaviourScript : MonoBehaviour {//public sjt(float x, float y);// 构造体Transform tran;//  主界面help //// Debug.Log(); // 打印// Use this for initializationvoid Start () {// 执行一次//Do();tran = this.gameObject.GetComponent<Transform>();//float posX = tran.position.x;//tran.position.x = 5;// errortran.position = new Vector3 (0, 0, 0);transform.position = new Vector3 (1, 1, 1);transform.localPosition = new Vector3 (1,1,1);// 界面属性上的position //transform.rotation = new Quaternion (30, 30, 30, 30);transform.localEulerAngles = new Vector3 (0, 30, 0);// 修改 Rotation transform.localScale = new Vector3 (2,2,2);// 局部缩放属性// this,指脚本 this 是c#的关键词// gameObject 所挂载的对象// Component 组件// Transform 指 泛型  http://baike.baidu.com/link?url=Uuau1uqsT-Ed_tzBB3QdLUnoelxdsCGgIWQICAsvm4ZABqZp8g1JFEmimc0IWXfXys9sVXTSslCyM21mJFNOqa}//void Do(string sjt)//{//int resultNum = num1 / num2;//Debug.Log(resultNum);//print (resultNum);//}// Update is called once per framevoid Update ()// 物体所有动的操作都要写到 Update({//print ("nihao!");}void OnGui(){GUI.skin.label.fontSize = 100;GUI.Label (new Rect(10, 10, Screen.width, Screen.height), "Hello World");}}
<pre name="code" class="cpp">using UnityEngine;using System.Collections;public class MainPlayer : MonoBehaviour {float move = 1;// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {if(Input.GetKey(KeyCode.RightArrow)){//this.transform.Translate (new Vector2(move, 0));this.gameObject.transform.position += new Vector3(1,0,0)*move *Time.deltaTime;}}}




                                             
0 0
原创粉丝点击