1.Start方法用来做初始化,只调用一次。
2.Update方法用来做更新,每帧调用一次。
3.Debug.Log();用来表示打印一行(全部都是在英文输入法下进行)。
4.如何打开控制台:在Window中点击Console打开。
1.Start方法用来做初始化,只调用一次。
2.Update方法用来做更新,每帧调用一次。
3.Debug.Log();用来表示打印一行(全部都是在英文输入法下进行)。
4.如何打开控制台:在Window中点击Console打开。
void Start(){
Debug.Log("Hello unity)
}
Debug是类,log是其中的方法
//无论脚本有没有启用 都会执行且执行一次 void Awake(){}
//初始化,在脚本启用初始化时执行一次,仅执行一次 void Start(){}
using UnityEngine;
public class Shoot : MonoBehaviour {
public GameObject bullet;
public float speed = 5;
// Use this for initialization
void Start () {
Debug.Log("--Hello Unity!");
//GameObject.Instantiate(bullet,transform.position,transform.rotation);
}
// Update is called once per frame
void Update () {
//Debug.Log("--Hello Unity! Update");
if ( Input.GetMouseButtonDown(0) )
{
GameObject b = GameObject.Instantiate(bullet, transform.position, transform.rotation);
Rigidbody rgd = b.GetComponent<Rigidbody>();
rgd.velocity = transform.forward * speed;
}
}
}
strat方法 执行一次
Updtae每一帧调用
C#脚本
每zhen
Debug.log("--hello unity");
Debug.Log("Hello,unity");
打开控制台Window