UEA0004: UseCompareTag
October 2, 2019 ยท View on GitHub
| Property | Value |
|---|---|
| Id | UEA0004 |
| Category | GC |
| Severity | Warning |
Example
Code with Diagnostic
using UnityEngine;
public class Example : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
// UEA0004: Using CompareTag for tag comparison does not cause allocations
if (other.tag == "Player")
{
}
}
}
Code with Fix
public class Example : MonoBehaviour
{
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Player"))
{
}
}
}