ToggleActiveRecursivelyAllGameObjects

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (typo)
m (Text replace - "<javascript>" to "<syntaxhighlight lang="javascript">")
Line 20: Line 20:
 
== JavaScript - ToggleActiveAllSelectedGO.js ==
 
== JavaScript - ToggleActiveAllSelectedGO.js ==
  
<javascript>
+
<syntaxhighlight lang="javascript">
 
@MenuItem ("Custom/Toggle Active All Selected GO's")
 
@MenuItem ("Custom/Toggle Active All Selected GO's")
 
static function ToggleAllSelected() {
 
static function ToggleAllSelected() {

Revision as of 20:48, 10 January 2012

Author: Martin Schultz (MartinSchultz)

Contents

Description

This little helper scripts toggles the active status of all selected game objects to the opposite and does as well for any linked children of the selected game objects, so a full recursive active toggle for all selected GOs.

The script can be found under the menu Custom→Toggle Active All Active Selected GO's.

Usage

You must place the script in a folder named Editor in your project's Assets folder for it to work properly.

Select some game objects and call select this script from the menu. It will toggle the active state instantly.

Screenshot

Toggleactivego.jpg


JavaScript - ToggleActiveAllSelectedGO.js

@MenuItem ("Custom/Toggle Active All Selected GO's")
static function ToggleAllSelected() {
	for (t in Selection.transforms) {
		t.gameObject.SetActiveRecursively(! t.gameObject.active);
	}
}
</javascript>
 
[[Category:Editor Scripts]]
[[Category:ScriptableObject]]
[[Category:JavaScript]]
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox