HierarchySelectObject

From Unify Community Wiki
(Difference between revisions)
Jump to: navigation, search
m (JavaScript - SelectMyObject.js)
m (Text replace - "</javascript>" to "</syntaxhighlight>")
 
(3 intermediate revisions by 2 users not shown)
Line 14: Line 14:
 
== JavaScript - SelectMyObject.js ==
 
== JavaScript - SelectMyObject.js ==
  
<javascript>
+
<syntaxhighlight lang="javascript">
  
 
@MenuItem ("Tools/Select My Object")
 
@MenuItem ("Tools/Select My Object")
static function SelectRaceManager() {
+
static function SelectMyObject() {
//var obj = GameObject.FindObjectOfType(RaceManager);
+
 
var obj = GameObject.Find("your object here from the hierarchy window");
 
var obj = GameObject.Find("your object here from the hierarchy window");
 
EditorGUIUtility.PingObject(obj);
 
EditorGUIUtility.PingObject(obj);
//Selection.activeGameObject = obj.gameObject;
 
 
Selection.activeGameObject = obj;
 
Selection.activeGameObject = obj;
 
}
 
}
</javascript>
+
 
 +
 
 +
// if you want to find a specific object identified by its class, like when an object has a RaceManager.js script attached to it.
 +
@MenuItem ("Tools/Select My Specific Object")
 +
static function SelectMySpecificObject() {
 +
var obj = GameObject.FindObjectOfType(RaceManager);
 +
EditorGUIUtility.PingObject(obj);
 +
Selection.activeGameObject = obj.gameObject;
 +
}
 +
</syntaxhighlight>
  
 
[[Category:Editor Scripts]]
 
[[Category:Editor Scripts]]
 
[[Category:JavaScript]]
 
[[Category:JavaScript]]

Latest revision as of 20:52, 10 January 2012

Author: Martin Schultz (MartinSchultz)

[edit] Description

Editor script that automatically selects and scrolls to a specific gameObject in Unity's hierarchy window. This is very useful if you have a large scale project with lots of objects in the hierarchy window and you want to quickly jump to a specific object you often need to jump to. This script scrolls automatically the hierarchy window to your object, pings it (gets highlighted in yellow) and gets also automatically selected so you can edit it in the inspector.

[edit] Usage

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

Define a gameObject from the hierarchy window that you often need, for example a "RaceManager" object or an "Boss Enemy".

[edit] JavaScript - SelectMyObject.js

@MenuItem ("Tools/Select My Object")
static function SelectMyObject() {
	var obj = GameObject.Find("your object here from the hierarchy window");
	EditorGUIUtility.PingObject(obj);
	Selection.activeGameObject = obj;
}
 
 
// if you want to find a specific object identified by its class, like when an object has a RaceManager.js script attached to it.
@MenuItem ("Tools/Select My Specific Object")
static function SelectMySpecificObject() {
	var obj = GameObject.FindObjectOfType(RaceManager);
	EditorGUIUtility.PingObject(obj);
	Selection.activeGameObject = obj.gameObject;
}
Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox