SetStatic

From Unify Community Wiki
Revision as of 20:48, 10 January 2012 by NCarter (Talk | contribs)

Jump to: navigation, search

By: DaveA

Description

Editor Utility that lets you set or clear the 'static' property on all selected objects and their children. Undoable!

Put this script into your project in the Editor folder. You will get the menu option GameObject->Set Static and GameObject->Clear Static

Code

Javascript - SetStatic.js

@MenuItem("GameObject/Set Static", false, 4) 
static function setStaticPicked() 
{ 
	Undo.RegisterSceneUndo ("Set Static");
	var trs = Selection.GetTransforms (SelectionMode.Deep);
	setStatic (trs, true);
} 
 
@MenuItem("GameObject/Clear Static", false, 4) 
static function clearStaticPicked() 
{
	Undo.RegisterSceneUndo ("Clear Static");
	var trs = Selection.GetTransforms (SelectionMode.Deep);
	setStatic (trs, false);
} 
 
static function setStatic(trs, state) 
{ 
	for (var tr in trs) 
	{ 
		tr.gameObject.isStatic = state;
	} 
} 
</javascript>
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox