- Home /
how to change a script property for multiple objects
Hello,
I am very new to Unity and trying to do the sound design of the Demo project named Angry Bots. In the process, I m in need of replacing sound clips of game objects.
For example, I needed to change the audio clip variable value in a class named AI attached to EnemySpider.
My question is, as there are many EnemySpiders, How can i simply change all the AI -> audioClip variable value at once from the unity editor ? Selecting all the AI and trying to change seems impossible due to nature of how inspector works.
Many Thanks my fellow designers.
Peace!
Answer by fish83 · Jun 22, 2014 at 03:32 AM
I was succeeded in selecting all the Enemy Spider AI scripts from the hierarchy , and then changing the script variable value by dragging and dropping the new sound asset to the field in the inspector.
It works fine.
Another solution that comes to my mind is to create a separate script/class which is not going to be attached to a game object, And have a predefined variable with the relevant common sound files. That class then can be used to create an object and use it in all the other Scripts/Classes. So changing only one Class variable will allow the associated sound to be changed across the game in all occurrences.
But if there is a better way of doing it please do add suggestions.
Your answer
![](https://koobas.hobune.stream/wayback/20220613152209im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Audio Play Once 2 Answers
Using multiple instances of the same script 1 Answer
Unity 3D Audio Clip Disabled 1 Answer