SetStatic

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
Line 11: Line 11:
 
== Javascript - SetStatic.js ==
 
== Javascript - SetStatic.js ==
  
<javascript>
+
<syntaxhighlight lang="javascript">
  
 
@MenuItem("GameObject/Set Static", false, 4)  
 
@MenuItem("GameObject/Set Static", false, 4)  

Revision as of 20:48, 10 January 2012

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