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.FindWithTag 查找标签
static function FindWithTag (tag : string) : GameObject
Description描述
Returns one active GameObject tagged tag. Returns null if no GameObject was found.
Tags must be declared in the tag manager before using them.
返回一个用tag做标识的活动的游戏物体,如果没有找到则为空。
标签必须在使用之前到标签管理器里面声明。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
public GameObject respawnPrefab;
public GameObject respawn = GameObject.FindWithTag("Respawn");
public void Awake() {
Instantiate(respawnPrefab, respawn.transform.position, respawn.transform.rotation);
}
}
//在标签为"Respawn"的游戏物体的位置实例化一个respawnPrefab.
var respawnPrefab : GameObject;
var respawn = GameObject.FindWithTag ("Respawn");
Instantiate (respawnPrefab, respawn.transform.position, respawn.transform.rotation);
最后修改:2011年5月19日 Thursday 22:13