MassSetMaterials

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
Line 25: Line 25:
 
}
 
}
  
</javascript>
+
</syntaxhighlight>

Latest revision as of 20:52, 10 January 2012

Original Author: Stelimar

[edit] Description

Allows you to set the materials of multiple objects at once. All of the selected objects will have their materials set to the same as the current active object (the object shown in the Inspector Window).

[edit] Usage

1.Place the MassSetMaterials.js script in YourProject/Assets/Editor.
2.Set the materials of one object to the desired materials.
3.Ctrl + click on the other objects to select them, making sure that the first object is still show in the Inspector Window.
4.Click Scripts > Mass Set Materials from the menu bar at the top of the screen.

[edit] Javascript - MassSetMaterials.js

@MenuItem("Scripts/Mass Set Materials")
static function MassSetMaterials() {
    Undo.RegisterSceneUndo("Mass Set Materials");
 
    var mats : Material[] = Selection.activeGameObject.renderer.sharedMaterials;
 
    for (var obj : GameObject in Selection.gameObjects) {
        obj.renderer.sharedMaterials = mats;
    }
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox