USP0008 Don't flag private methods used with Invoke/InvokeRepeating or StartCoroutine/StopCoroutine as unused
February 28, 2020 ยท View on GitHub
Private methods used with Invoke, InvokeRepeating, StartCoroutine or StopCoroutine are not unused.
Suppressed Diagnostic ID
IDE0051 - Remove unused private members
Examples of code that produces a suppressed diagnostic
using UnityEngine;
class Camera : MonoBehaviour
{
void Start()
{
Invoke("InvokeMe", 10.0f);
}
private void InvokeMe()
{
// Invoke me
}
}
Why is the diagnostic reported?
The IDE cannot detect any calls to InvokeMe in the class.
Why do we suppress this diagnostic?
InvokeMe is called indirectly by Unity, which is undetectable by the IDE.