[SerializeField] instead public

Hello everyone.
I am wondering a little question - is it good practice to use [SerializeField] instead public access modifier for setting up values via inspector?

I guess it’s a question that doesn’t have a right or wrong answer.

Personally, I hate that unity so frequently provides access to members that should be private.

In true OOP fashion I wrap everything with getters and setters to encapsulate my data:

public class PrivateData : MonoBehaviour
{
    [SerializeField, HideInInspector] private int m_Number;

    public int number {get {return m_Number;} set {m_Number = value;}}
}

Finally you can expose this by writing a custom inspector

[CustomEditor(typeof(PrivateData))]
public class PrivateDataInspector : Editor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        PrivateData castTarget = target as PrivateData;

        castTarget.number = EditorGUILayout.IntField("Number", castTarget.number);
    }
}

You can see there’s a bit of overhead, but personally I think it’s worth it for bullet-proof code.