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.CompareTag 比较标签
function CompareTag (tag : string) : bool
Description描述
Is this game object tagged with tag?
这个游戏物体是否被标识tag标签?
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag("Player"))
Destroy(other.gameObject);
}
}
// Immediate death trigger.
// Destroys any colliders that enter the trigger, if they are tagged player.
// 立即销毁trigger的游戏物体.
// 如果一切进入这个trigger的碰撞体被标识了,则销毁它.
function OnTriggerEnter (other : Collider) {
if (other.gameObject.CompareTag ("Player")) {
Destroy (other.gameObject);
}
}
最后修改:2010年12月13日 Monday 18:11