Answer the question
In order to leave comments, you need to log in
How do I attach a prefab to a script in Unity so that all objects on the stage execute the code?
Good day.
The blue color in the screenshot circles the objects that are on the stage (these are two stairs), which, when attached to the script, work, but only separately, since only one GameObject was specified in the script. public GameObject platform_ladder;
When trying to attach to the Script Inspector (highlighted in yellow) Prefab (circled in red) everything stops working. Although the objects on the stage are this prefab.
On this basis, the question arose:
How, without creating +100500 GameObjects, can a prefab be used as a single object? And is it even possible to do this?
Answer the question
In order to leave comments, you need to log in
Try to select a script in the project files and set the desired prefab in the inspector of the game object variable. In theory, then it should be used by default.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question