Add prefab to a non exposed variable

I wonder if it’s possible to assign a prefab gameobject to a (non exposed) variable with scripting. Or is the only way to do this to drag and drop a prefab using the inspector?

In Editor scripts there are ways of searching the prefabs that are not attached to the scene in anyway. For runtime codeing (ie. your actual game) I think if the prefab is not referenced some how by an object in the scene Unity will nt include it in build, this stops your builds from being huge and filled with used cluter. If you have reference to a prefab you can assign it like any other object.

It is common to keep an offscreen depot of objects that may be needed in a scene, and just bring them or instantiate a copy when needed.

Cheers,
Grant

In Editor scripts there are ways of searching the prefabs that are not attached to the scene in anyway. For runtime codeing (ie. your actual game) I think if the prefab is not referenced some how by an object in the scene Unity will nt include it in build, this stops your builds from being huge and filled with used cluter. If you have reference to a prefab you can assign it like any other object.

It is common to keep an offscreen depot of objects that may be needed in a scene, and just bring them or instantiate a copy when needed.

Cheers,
Grant