You add a "folder" to the Hierarchy in Unity by creating an empty GameObject and using it as a parent for other GameObjects.
Unlike the Project view, where you create actual folders to organize assets, the Hierarchy view uses GameObjects to structure your scene. Grouping GameObjects under an empty parent GameObject helps keep your scene organized and manageable, especially in larger projects.
Steps to Create a Hierarchy "Folder"
Follow these simple steps to create a parent GameObject that acts like a folder in your Unity Hierarchy:
- Open your Scene: Ensure you have a scene open in Unity.
- Create an Empty GameObject:
- Right-click anywhere in the Hierarchy window.
- Select Create Empty.
- Alternatively, go to the main menu and select
GameObject > Create Empty
.
- Rename the Empty GameObject: Select the newly created
GameObject
in the Hierarchy and pressF2
(or right-click and selectRename
). Give it a descriptive name like "Environment," "PlayerObjects," "UI Elements," or "Lights." This name will serve as your "folder" title. - Organize Your GameObjects:
- Drag and drop gameobjects from the Hierarchy onto your newly renamed empty GameObject. When you drag, ensure the empty GameObject is highlighted before releasing the mouse button.
- The dragged GameObjects will now appear indented underneath the parent empty GameObject, becoming its children.
Action | Effect in Hierarchy |
---|---|
Create Empty GameObject | Adds a new `GameObject` (e.g., "Folder Name") |
Drag Object A onto "Folder Name" | Object A becomes a child of "Folder Name" and is indented |
Drag Object B onto "Folder Name" | Object B becomes a child of "Folder Name" and is indented |
Why Use Empty GameObjects for Organization?
- Clarity: They make your Hierarchy easier to read and navigate.
- Bulk Operations: You can easily move, rotate, scale, enable, or disable the parent GameObject (your "folder"), affecting all its children simultaneously.
- Hierarchical Logic: This structure helps represent relationships between objects in your scene (e.g., a character and their equipment, or different parts of a building).
As mentioned in the reference: "In hierarchy view: Create an empty gameobject to serve as a folder. Drag and drop gameobjects to make them children." This is the standard method for organizing GameObjects visually within your scene's hierarchy. Remember that this method is distinct from creating folders in the Project view, which are used for managing asset files.