I’m confused about the type of objects in my scripts. I have a prefab called Enemy, with a script called EnemyScript. Unity seems pretty happy when I pass the prefab in with type EnemyScript. But isn’t that just one component of Enemy? What would happen if there were multiple scripts associated with Enemy – could I bring in the prefab with any of these types? Could I set the type of the prefab to simply be Enemy?
When my script assigns a value to transform, shouldn’t it really be setting transform of the gameObject with which the script is associated? Or it that what’s happening, and Unity is just being clever and doing that mapping for me? It feels weird that sometimes I refer to an object by one of its scripts. Likewise, sometimes it seems like I’m meant to refer to an object by its transform.
So what is the type of my prefab? Is it a gameObject, any script in the prefab, the name of the prefab itself, a transform, or something else? And if more than one of these is feasible, what are the implications of the various options?
Any help would be much appreciated. Thanks very much in advance.