# SerializeField vs GetComponent Efficiency

As far as I know, there are two built in ways to get an instance of a component in Unity.

1 - Serialize the field and drag in the component manually in the editor

[SerializeField] private MyScript script;


2 - Using MonoBehaviour's GetComponent method

script = GetComponent<MyScript>();


I would think that it is more efficient to drag the component in the editor lest making the engine illiterate through every component in the GameObject to find the component.

Is it more or less efficient to drag the component in the editor compared to using GetComponent? Or does Unity find components in a different way or dragging components in the editor is handled in a different way such that it would be more efficient to use GetComponent? Would using one over the other have any impact on performance in the real world?

A similar question would also be raised regarding GameObject.FindGameObjectWithTag() vs dragging in the editor.

As far as optimization go, should you use one method over another?

• It seems like we get a lot of questions that turn out to be problems with components referenced by serialized fields, but that could be my imagination. – jzx Aug 4 '15 at 4:34