USP0003 The Unity runtime invokes Unity messages

February 4, 2020 ยท View on GitHub

Unity messages should not be flagged as unused because Unity invokes those messages.

Suppressed Diagnostic ID

IDE0051 - Remove unused private members

Examples of code that produces a suppressed diagnostic

using UnityEngine;

class Camera : MonoBehaviour
{
	void Start()
	{
		//Some code
	}

	void Update()
	{
		//Some code
	}
}

Why is the diagnostic reported?

The IDE cannot find any references to the methods Start and Update, and believes them to be unused.

Why do we suppress this diagnostic?

Even though the IDE cannot find any references to Start and Update, they will be called by Unity, and should not be removed.