Is there any disadvantage of that / is it bad habit? Let’s say I have enemy that get’s instantiated every a while (I don’t use object pooling for now). The enemy has few GetComponents in Start() so I want to remove every possible lag spike on spawn, so I use [SerializeField] for Animator and NavMeshAgent that are on the exact gameobject this script is on.
The theoretical answer would be that it is faster to assign the references in the inspector, since
GetComponent uses a lookup table to find if the component is on the GameObject
However, in reality, it would not make a difference. These are such micro-optimizations that when you get to the point where they might start to make a difference, other factors come into play that are much more impactful.
Say for example that you would spawn 10.000 of these enemies in one frame, this would cause such an overhead that the way you assign the reference is completely irrelevant.