Using prefab to init a component SerializeField

A SerializeField was defined in a script “EnemySpawner.cs” like this :
[SerializeField] EnemyMovement enemyPrefab;

EnemyMovement is a component but you were able to drag and drop an enemy prefab into it. What happens behind the scene to support this?

Hi Svet,

Welcome to our community! :slight_smile:

Unfortunately, most parts of Unity are not open-source, so we often do not know what is going on behind the scenes. That is also the case here.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms