Unity3D笔记1 动态创建对象

 

 

在IDE中调整好Main Camera 设置Z为-20.

直接把脚本绑定在这上面

 
using UnityEngine;
using System.Collections;

public class CreateObject : MonoBehaviour 
{
	void Start () 
	{
		GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Plane);
		GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
		cube.transform.position = new Vector3(0, 0.5F, 0);
		GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
		sphere.transform.position = new Vector3(0, 1.5F, 0);
		GameObject capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);
		capsule.transform.position = new Vector3(2, 1, 0);
		GameObject cylinder = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
		cylinder.transform.position = new Vector3(-2, 1, 0);
	}
}

你可能感兴趣的:(Unity3d笔记)