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.
Hierarchy
panel.Project
panel drag & drop your script into Inspector
panel.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:
gameObject.AddComponent ("FoobarScript");
Clearly you must recognize all the objects. (example you can use FindGameObjectsWithTag) Full example:
objList = GameObject.FindGameObjectsWithTag("MeaningfullTagName");
foreach (GameObject obj in objList ) {
obj.AddComponent ("YourScript");"
}