Unity – Encapsulate a property in code but expose it to the inspector

1
2
[SerializeField]
private GameObject hiddenObject;
[SerializeField]
private GameObject hiddenObject;

This allows you to keep your code clean by hiding and restricting access to your properties while still being able to tweak the values from the Unity inspector.