USP0015 The Unity runtime invokes Unity messages

March 2, 2022 ยท View on GitHub

Unused parameters should not be removed from Unity messages.

Suppressed Diagnostic ID

CA1801 - Remove the parameter or use it in the method body.

Examples of code that produces a suppressed diagnostic

using UnityEngine;

class Camera : MonoBehaviour
{
	void OnCollisionEnter(Collision c)
	{
		// do stuff, but c remains unused
	}
}

Why is the diagnostic reported?

The Code Quality analyzer does not detect that you've used c, and under normal circumstances, it would be reasonable to remove the unused parameter.

Why do we suppress this diagnostic?

The Code Quality analyzer doesn't realize this is a Unity message, and therefore has no way of determining that it needs to have a specific signature to function correctly.