UEA0004: UseCompareTag

October 2, 2019 ยท View on GitHub

PropertyValue
IdUEA0004
CategoryGC
SeverityWarning

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"))
        {

        }
    }
}