Skip to main content
1 of 2

Create Unity Editor script to do same action for multiple objects

I have a lot of duplicated objects, and I need in editor, not in the game, apply some changes to the objects (remove specific material). Of course I can do this manually, but there are a lot of them.

In case of Javascript, you can just open console, and get all stuff You need by methods like getElementsByClassName. It would be perfect if some similar functionality exist (at least as addons) in Unity.

I do not need some UI for using script currently, and I also do not need to run it on Unity launch. I want to call it every time by pressing some key in editor.

So, seems that I have to enumarate all game objects, get their meshes, check GUID, and if it equals to that I need, then enumarete object's materials list, find by GUID material I need, and call some remove method to it.

Point me where I should look, and should learn to achive that.