variables in prefab scripts

When I have a variable reference like var test : Transform from a script in a prefab is there something i need to drag onto the variable reference in the script component in the inspector? The asset click at the far right brings up an empty window.
I broke a prefab and now the ‘var test : transform’ doesn’t hook onto anything and at runtime I get :

Setting the parent of a transform which resides in a prefab is disabled
to prevent data corruption.
opponentmove:FixedUpdate() (at


MissingComponentException: There is no
‘Rigidbody’ attached to the “cueb”
game object, but a script is trying to
access it. You probably need to add a
Rigidbody to the game object “cueb”.
Or your script needs to check if the
component is attached before using it.
(Vector3 force) (at
opponentmove.FixedUpdate () (at

I have a prefab that is similar and can only see the difference in the inspector like mentioned above.


It surely looks like you’re just asking about the point of an iceberg here.

To put it simply: if you declare a public variable in a script, and you attach that script to an object, you usually do that to actually drag an object of the specified type into the variable slot in the inspector, you are however not forced to do that: it completely depends on your code (for example nobody stops you from declaring a public var there and instantiating it by code. being it public would allow other scripts to access it).