GameObject.GameObject 游戏物体

static function GameObject (name : string) : GameObject

Description描述

Creates a new game object, named name.
A Transform is always added to the game object.

创建一个新的游戏物体,命名为name。
游戏物体总是会带有一个变换(Transform)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public GameObject player;
	public void Awake() {
		player = new GameObject("Player");
		player.AddComponent("Rigidbody");
		player.AddComponent("BoxCollider");
	}
}
// 创建一个名字叫"Player"的游戏物体,并且给它添加一个刚体和盒子碰撞器.
var player : GameObject;
player = new GameObject ("Player");
player.AddComponent ("Rigidbody");
player.AddComponent ("BoxCollider");

• static function GameObject () : GameObject

Description描述

Creates a new game object.
A Transform is always added to the game object.

创建一个新的游戏物体,名字是name。
游戏物体总是会带有一个变换(Transform)。

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
	public GameObject player;
	public void Awake() {
		player = new GameObject();
		player.AddComponent("Rigidbody");
		player.AddComponent("BoxCollider");
	}
}
// 创建一个没有名字的游戏物体,并且给它添加一个刚体和盒子碰撞器.
var player : GameObject;
player = new GameObject ();
player.AddComponent ("Rigidbody");
player.AddComponent ("BoxCollider");

• static function GameObject (name : string, params components : Type[]) : GameObject

Description描述

Creates a game object and attaches the specified components.
创建一个游戏物体,并且附加特定的组件.

Page last updated: 2011-5-19