本文整理汇总了C#中UnityEngine.Component.CompareTag方法的典型用法代码示例。如果您正苦于以下问题:C# Component.CompareTag方法的具体用法?C# Component.CompareTag怎么用?C# Component.CompareTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UnityEngine.Component
的用法示例。
在下文中一共展示了Component.CompareTag方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerStay
void OnTriggerStay(Component component) {
if (component.CompareTag("LevelPoint")) {
GameManager.LevelCompleted = true;
anim.SetBool("Attacking", false);
anim.SetBool("Walking", true);
if (transform.position.x < component.gameObject.transform.position.x) {
GetComponent<Rigidbody>().velocity = new Vector3(0f, 1f, 0f);
float step = 2f * Time.deltaTime;
transform.position = Vector3.MoveTowards(transform.position, component.gameObject.transform.position, step);
} else {
GetComponent<Rigidbody>().velocity = new Vector3(0f, 5f, 0f);
}
}
}
示例2: OnTriggerEnter
void OnTriggerEnter(Component component) {
if (component.CompareTag("CheckPoint")) {
LastCheckPoint = component.gameObject;
component.gameObject.SetActive(false);
}
if (component.CompareTag("ActionPoint")) {
component.gameObject.SetActive(false);
}
if (component.CompareTag("BadTouch") || (component.CompareTag("Enemy") && !Attacking)) {
Kill();
}
if (component.CompareTag("Fallable")) {
GetComponent<Collider>().isTrigger = false;
component.GetComponent<Fallable>().Fall();
}
if (component.CompareTag("Breakable")) {
component.GetComponent<Breakable>().Break();
}
}
示例3: AreEnemies
public static bool AreEnemies(Component c1, Component c2)
{
return !c1.CompareTag(c2.tag);
}
示例4: OnTriggerEnter
void OnTriggerEnter(Component component) {
if (component.CompareTag("Player") && Player.Attacking) {
Break();
}
}
示例5: Contains
public bool Contains(Component component)
{
return (!component ? false : component.CompareTag(GameConstant.Tag.Info[this.tagNumber].tag));
}
示例6: FindDependency
public override object FindDependency(Component comp, FieldInfo field)
{
if (SearchParents) {
comp = comp.transform.root;
}
if (IsContainerType(field)) {
List<GameObject> deps = new List<GameObject>();
if (comp.CompareTag(Tag)) {
deps.Add(comp.gameObject);
}
FindDependenciesInternal(comp.gameObject, deps);
return CreateArrayOrList(field, deps);
}
if (comp.CompareTag(Tag)) {
return ExtractComponent(comp.gameObject, field.FieldType);
}
GameObject dep = FindDependencyInternal(comp.gameObject);
return ExtractComponent(dep, field.FieldType);
}