In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects.
I'm a beginner & learning scripts in Unity.
Edit: At the time of editing the scene itself.
In Unity, I've almost 200 or more objects. I wish to apply single script to all those objects. I'm a beginner & learning scripts in Unity. Edit: At the time of editing the scene itself. |
|||||
|
Here are the steps for applying scripts to multiple objects.
|
|||||||||||||
|
You can add script at runtime. You can create an empty objects with a script that "browse" the 200 or more objects and atach the sript to each of them Example: to add the script named FoobarScript to the game object use:
Clearly you must recognize all the objects. (example you can use FindGameObjectsWithTag) Full example:
|
|||||
|