Skip to content

Latest commit

 

History

History
40 lines (30 loc) · 969 Bytes

UNT0021.md

File metadata and controls

40 lines (30 loc) · 969 Bytes

UNT0021 Unity message should be protected

All Unity messages should be protected. Unity messages do not need to be public for Unity to call them and are not meant to be called manually. Also, if a base class has a private message and a child class implements the same one, only the child one will be called without any notification or any way to call the base method.

You have to opt-in to use this analyzer (disabled by default). To enable it, you will need to add the following to your .editorconfig file:

[*.cs]
dotnet_diagnostic.UNT0021.severity = suggestion

Examples of patterns that are flagged by this analyzer

using UnityEngine;

class Camera : MonoBehaviour
{
    public void Awake
    {
    }
}

Solution

Fix expression:

using UnityEngine;

class Camera : MonoBehaviour
{
    protected void Awake
    {
    }
}

A code fix is offered for this diagnostic to automatically apply this change.