The GameObjectSelector script is a versatile and user-friendly editor window for Unity, offering a wide range of options to efficiently select GameObjects in the scene. Whether it's filtering by name, script, layer, or component, or using dedicated buttons, this script empowers developers to easily target specific elements. Additionally, it provides the convenience of hiding/unhiding GameObjects in both Hierarchy and Scene views, ensuring a clutter-free editing experience. The script also enables grouping selected objects under an empty parent GameObject or moving them to an existing GameObject for seamless organization. With a console log displaying the number of selected GameObjects, the "GameObject Selector" enhances productivity and simplifies Unity development, making it an enjoyable and efficient journey for all developers.
-
General Selection: Select all GameObjects, Cameras, or Lights in the scene with just a single click.
-
Audio Objects Selection: Quickly select GameObjects with Audio Source or Audio Reverb Zone components for audio-related tasks.
-
Effects Selection: Easily select GameObjects with Particle Systems, Trail Renderers, or Line Renderers for effect-related operations.
-
Search by Name: Search for GameObjects by name using keywords, numbers, or letters, making it effortless to locate specific objects in complex scenes.
-
Search by Script: Select all GameObjects that contain a specific script by simply dragging and dropping the script into the tool.
-
Search by Layer: Choose a layer from a list of used layers in the scene to select all GameObjects assigned to that layer.
-
Search by Component: Select GameObjects that have a specific component from the list of used components in the scene.
-
Create Empty Object and Move Selection: Create a new empty GameObject and move the selected objects inside it, streamlining scene organization.
-
Move Selected Objects to Existing GameObject: Move the selected objects into an existing GameObject for hierarchical structuring.
-
Hide/Show GameObjects in Hierarchy: Hide or show unselected GameObjects in the Hierarchy window, focusing on the selected GameObjects.
-
Hide Unselected in Scene: Option to hide GameObjects in the Scene view that are also hidden in the Hierarchy view.
-
Keep Selected GameObjects in Hierarchy: Preserve selected GameObjects in the Hierarchy view while applying hide/unhide options.
*Working in Unity 2022.3.5f1 and 2021.
- Open Unity and drag script into
Editor
folder of your Unity project. - Go to the
Window
menu. - Find and select
GameObject Selector
from the menu to open the window.
- Click on one of the buttons in this section to select GameObjects based on the specified criteria.
- Click on one of the buttons in this section to select GameObjects specific to audio components.
- Click on one of the buttons in this section to select GameObjects specific to visual effects components.
- Enter a search query in the "Search Name" field.
- Click the "Search" button to find and select GameObjects that match the search query.
- Drag and drop a script file into the "Drag Script Here" field.
- Click the "Search" button to find and select GameObjects that contain the specified script.
- Select a layer from the "Select Layer" dropdown.
- Click the "Select" button to find and select GameObjects on the chosen layer.
- Select a component from the "Select Component" dropdown menu.
- Click the "Select" button to find and select GameObjects that contain the chosen component.
- Enter a name for the empty GameObject in the "Empty Object Name" field.
- Click the "Create Empty and Move" button to create the empty GameObject and move selected objects inside it.
- Drag and drop an existing GameObject into the "Drag GameObject Here" field.
- Select the GameObjects you want to move.
- Click the "Move Selected GameObjects" button to move the selected GameObjects to the target GameObject.
- Check/uncheck the options as needed:
- Hide GameObjects in Hierarchy: Hides unselected GameObjects in the Hierarchy view.
- Hide Unselected in Scene: Hides GameObjects in the Scene view that are also hidden in the Hierarchy view.
This feature works with Hide GameObject bool = true.
- Keep Selected GameObjects in Hierarchy: Prevents the script from hiding selected GameObjects in the Hierarchy view when Hide GameObjects in Hierarchy is enabled.
This feature works with Hide GameObject bool = true.
- The script will apply the options and perform the necessary operations to hide/unhide GameObjects and manage the Hierarchy view.
- The script uses
EditorGUILayout
andEditorGUI
to create the editor window interface. - It subscribes to Unity events such as
EditorApplication.hierarchyWindowItemOnGUI
andSceneView.duringSceneGui
to implement features like hiding GameObjects in the Hierarchy and Scene views. - Be cautious while using the "Move Selected Objects to Existing GameObject" option, as moving objects in the scene can have unintended consequences.
- This script is intended for use within Unity's UnityEditor, and it enhances productivity by simplifying GameObject selection and management tasks, saving valuable development time. It is a powerful tool for developers and designers working on Unity projects with complex scenes and large numbers of GameObjects.
Remember to save your scene and project regularly, especially when using custom editor scripts, as they can cause changes that are not always undoable. Use this script responsibly and make sure to understand its implications before applying it to your project.
Use at your own risk. Im not responsible if you crash your project. Try first at blank and always make backup before trying new assets/scripts in editor.