c#:创建物体

c#:创建物体_第1张图片

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {

	public GameObject prefab;
	public GameObject wuti;

	// Use this for initialization
	void Start () {
		//unity的构造方法
		//第一种
		Object.Instantiate(prefab,new Vector3(12,45,56),Quaternion.identity);
		//第二种:通过GameObject()方法new一个新物体
		//wuti=new GameObject("这就是我");
		//第三种,
		GameObject.CreatePrimitive(PrimitiveType.Sphere);
	}
	
	// Update is called once per frame
	void Update () {
		
	}
}

你可能感兴趣的:(unity)