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);

	}

}
Page last updated: 2010-12-11