# Changing properties for multiple objects in unity 3d free?

So my team and I need to assign values to specific values in the inspector to large numbers of objects.

For example, we have a script that's assigned to all the walls, and all the floors.

We want to select all the walls in the Scene view and assign the value "1" to a variable in the inspector and then go and select all the floors and assign the value "2" to the same variable, for those objects.

Right now, when we select multiple objects and assign a value to the variable in the inspector, it just changes it for the last selected object.

We've got (potentially) hundreds of object that we need to do this to and it would suck to have to go in and change the values one at a time.

The equivalent I'm thinking of is the Attribute Spreadsheet in Maya, where you can see a list of objects, and assign the same value to a bunch of their attributes.

Hope somebody out there has an answer for this! Haven't been able to find one yet!

• Maybe I get it wrong, but normally this is why we can use prefabs. this way you can change a prefab in your project and the values will get applied to all game objects of this type, connected to the prefab – XandruCea Sep 3 '15 at 9:24

I don't know the specific limitations of Unity Free, but I wrote a little editor tool to do something like that.

Basically it consists of an editor window with a bunch of object fields setup to take game objects.

Whenever one of those object fields changes, it uses something like GetComponent<MonoBehaviour>() to determine what components are on those objects. It then populates a list of which components are shared between all of the game objects. When the user selects the field, it uses standard .NET reflection to determine which fields are either 1) public or 2) marked with SerializeField.

From there, of those fields, it displays editor fields for those types that make sense. So int editor fields for int fields in the class, etc. I think I store this in a Dictionary<Type,object> or something similar. I may store a bool with it as well so that you can check which fields you want to actually be applied.

Then when the user clicks the editor button, it goes through each of those game objects, gets that component, and sets the field value to be what's in the editor gui fields. I think I also had to do this with reflection, I don't have the code in front of me.

Now if you're going for something a little less general, you can do something similar where you only check for the predefined component instead of using reflection, but the concepts would be the same.

Unfortunately I couldn't find any way of showing something like the inspector gui shows for a given component without using a specific instance of that component, and Unity doesn't have any nice built in editor fields for things like arrays of serializable types and that kind of thing.

• Thanks for the response! Do you have that tool available for download by any chance? hopeful – raphaeltm Oct 28 '11 at 15:44
• It's a proprietary tool that I wrote for work, so no. – Tetrad Oct 29 '11 at 0:12