按空格按键生成预设体

using UnityEngine;
using System.Collections;

public class InitGameObject : MonoBehaviour {

	public GameObject bullet;

	void Update()
	{
		if (Input.GetKeyDown (KeyCode.Space)) {
			//通过预设体生成游戏对象(预设体,位置,旋转(四元数))
			GameObject blt =
				Instantiate(bullet,
					new Vector3(1,0,0),
					Quaternion.identity) as GameObject;
			Debug.Log (blt.name);
		}
	}

}

  

posted @ 2016-10-29 15:42  扎北强子  阅读(285)  评论(0编辑  收藏  举报