Component
- animation
- audio
- BroadcastMessage
- camera
- collider
- CompareTag
- constantForce
- gameObject
- GetComponent.<T>
- GetComponentInChildren.<T>
- GetComponentInChildren
- GetComponents.<T>
- GetComponentsInChildren.<T>
- GetComponentsInChildren
- GetComponents
- GetComponent
- guiTexture
- guiText
- hingeJoint
- light
- networkView
- particleEmitter
- renderer
- rigidbody
- SendMessageUpwards
- SendMessage
- tag
- transform
Component.CompareTag 比较标签
function CompareTag (tag : string) : bool
Description描述
Is this game object tagged tag?
游戏物体有被标记标签么?
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
void OnTriggerEnter(Collider other) {
if (other.CompareTag("Player"))
Destroy(other.gameObject);
}
}
// Immediate death trigger.
//立即死亡触发器
// Destroys any colliders that enter the trigger, if they are tagged player.
//如果它们标签是player,进入这个触发器将销毁任何碰撞。
function OnTriggerEnter (other : Collider) {
if (other.CompareTag ("Player")) {
Destroy (other.gameObject);
}
}
最后修改:2010年12月11日 Saturday 15:51