GameObject
- active
- AddComponent.<T>
- AddComponent
- animation
- audio
- BroadcastMessage
- camera
- collider
- CompareTag
- constantForce
- CreatePrimitive
- FindGameObjectsWithTag
- FindWithTag
- Find
- GameObject
- GetComponent.<T>
- GetComponentInChildren.<T>
- GetComponentInChildren
- GetComponents.<T>
- GetComponentsInChildren.<T>
- GetComponentsInChildren
- GetComponents
- GetComponent
- guiTexture
- guiText
- hingeJoint
- isStatic
- layer
- light
- networkView
- particleEmitter
- renderer
- rigidbody
- SampleAnimation
- SendMessageUpwards
- SendMessage
- SetActiveRecursively
- tag
- transform
GameObject.CreatePrimitive 创建基本物体
static function CreatePrimitive (type : PrimitiveType) : GameObject
Description描述
Creates a game object with a primitive mesh renderer and appropriate collider.
创建一个带有基本网格渲染器和相应碰撞器的游戏物体。
using UnityEngine;
using System.Collections;
public class example : 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);
}
}
//在场景中创建一个平面,球体,立方体,胶囊,圆柱体
function Start () {
var plane : GameObject = GameObject.CreatePrimitive(PrimitiveType.Plane);
var cube : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.transform.position = Vector3(0, 0.5, 0);
var sphere : GameObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = Vector3(0, 1.5, 0);
var capsule : GameObject = GameObject.CreatePrimitive(PrimitiveType.Capsule);
capsule.transform.position = Vector3(2, 1, 0);
var cylinder : GameObject = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
cylinder.transform.position = Vector3(-2, 1, 0);
}
最后修改:2011年7月14日 Thursday 10:20