Just as a useful tip, instead of assuming a component is present in your Awake/Start call, you can enforce it with the RequireComponent attribute:
[RequireComponent(typeof(MeshRenderer))]
public class UnitSelectedVisual : MonoBehaviour
{
[SerializeField] private Unit _unit;
private MeshRenderer _meshRenderer;
private void Awake()
{
_meshRenderer = GetComponent<MeshRenderer>();
}
}