SaintsHierarchy
SaintsHierarchy enhances the Unity hierarchy inspector with visual organization tools and quick-access features. It provides indent guides, customizable GameObject icons, automatic icons for common components (Camera, Canvas, Light), favorite items management, component icon display, and enabled state checkers to streamline scene navigation and debugging.
today.comes.saintshierarchy Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/saintshierarchy.git README Markdown
Copy this to your project's README.md
## Installation
Add **SaintsHierarchy** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/saintshierarchy.git
```
[](https://www.pkglnk.dev/pkg/saintshierarchy)README
Saints Hierarchy
Unity Hierarchy enhancement. Use Alt+Left Mouse Button to select.
Features
- Draw indent guild
- Allow set icons (pre-set & custom)
- Auto set icons for camera, cavans, light, eventSystem & Wwise Initializer
- Prefab footer icon if you have custom icon set
Config
This will automaticlly add indent tree, and icon for camera, light, canvas, event system, wwise
Tools - SaintsHierarchy - Disable Saints Hierarchy to disable this plugin
Favorite GameObjects
You can disable this feature in Tools - SaintsHierarchy - Disable Favorites
Drag & Drop GameObject from hierarchy to the top space to add it to favorite.
- Clicking the favorited button to quickly arrive the object in hierarchy
- Draging it to adjust the favorite items' order
- Right click (or
alt+ click) the favorite button to change alias, icon, or remove it from favorite
[!NOTE]
- ATM the config is saved under personal config (so won't be saved by git), and can not be saved to team-shared config
- ATM it can not show custom icons etc
Background Strip
Tools - SaintsHierarchy - Background Strip
Component Icons
Tools - SaintsHierarchy - Component Icons
You can set the script icon and show the icons at the end of row
Setup:
Result:
GameObject Enabled Checker
Tools - SaintsHierarchy - GameObject Enabled Checker
Add a checkbox at the end for gameObject which has any disabled parent gameObjects, to quickly toggle it back.
GameObject Enabled Checker On Every Row
Tools - SaintsHierarchy - GameObject Enabled Checker Every Row
This add checkbox for every row instead of undering disabled parent ones.
No Default Icon
No longer draw the default white box icon if no icon for this gameObject.
Transparent Default Icon
Draw a transparent box icon if no icon for this gameObject.
Usage
GameObject Icon
GameObject icon (including custom icons) will be used as hierarchy icon:
Result:
GameObject label will be used as hierarchy label underline:
Result:
Color
- select a color to change
- use
xbutton to clean the color config - use the color picker (second button) to manually change the color you want
Custom Icon
- select an icon to change
- to use your custom icon, first right click on you icon - copy path, then paste it into the search field. The icon will appear as the first item on the result
- select the same icon to remove icon config
Scripted Icon
public class HierarchyIconPathExample : MonoBehaviour, IHierarchyIconPath
{
public string HierarchyIconPath => "CollabChanges Icon"; // return a path or name of the icon
}
Or
public class HierarchyIconTexture2DExample: MonoBehaviour, IHierarchyIconTexture2D
{
public Texture2D texture2D;
#if UNITY_EDITOR
public Texture2D HierarchyIconTexture2D => texture2D; // return a texture2D object; null to use default behavor
#endif
}
HierarchyLabel/HierarchyLeftLabel
Draw label. Callback & tag supported.
Parameters:
string label = null: label to draw. Use"$" + nameto make a callback/propertystring tooltip = null: tooltip to show
using SaintsHierarchy;
[HierarchyLabel("<color=CadetBlue><field/>")]
[HierarchyLeftLabel("<color=CadetBlue>|LEFT|")]
public string content;
HierarchyButton/HierarchyLeftButton/HierarchyGhostButton/HierarchyGhostLeftButton
Draw button. Callback & tag supported.
Parameters:
string label = null: label of the button.nullto use function name. use"$" + nameto use a callback labelstring tooltip = null: tooltip to show
using SaintsHierarchy;
public string c;
[HierarchyGhostButton("$" + nameof(c), "Click Me!")] // dynamic label
private void OnBtnClick()
{
Debug.Log($"click {c}");
}
[HierarchyLeftButton("C <color=Burlywood>Left")]
private void LeftClick()
{
Debug.Log("Left Click");
}
HierarchyDraw/HierarchyLeftDraw
Manually draw content
Parameters:
string groupBy = null: group the items virtically by this name. Ifnull, it will not share space with anyone.
Signature:
The method must have this signaure:
HierarchyUsed FuncName(HierarchyArea hierarchyArea)
HierarchyArea has the following fields:
/// <summary>
/// Rect.y for drawing
/// </summary>
public readonly float Y;
/// <summary>
/// Rect.height for drawing
/// </summary>
public readonly float Height;
/// <summary>
/// the x value where the title (gameObject name) started
/// </summary>
public readonly float TitleStartX;
/// <summary>
/// the x value where the title (gameObject name) ended
/// </summary>
public readonly float TitleEndX;
/// <summary>
/// the x value where the empty space start. You may want to start draw here
/// </summary>
public readonly float SpaceStartX;
/// <summary>
/// the x value where the empty space ends. When drawing from right, you need to backward drawing starts here
/// </summary>
public readonly float SpaceEndX;
/// <summary>
/// The x drawing position. It's recommend to use this as your start drawing point, as SaintsHierarchy will
/// change this value accordingly everytime an item is drawn.
/// </summary>
public readonly float GroupStartX;
/// <summary>
/// When using `GroupBy`, you can see the vertical rect which already used by others in this group
/// </summary>
public readonly IReadOnlyList<Rect> GroupUsedRect;
public float TitleWidth => TitleEndX - TitleStartX;
public float SpaceWidth => SpaceEndX - SpaceStartX;
/// <summary>
/// A quick way to make a rect
/// </summary>
/// <param name="x">where to start</param>
/// <param name="width">width of the rect</param>
/// <returns>rect space you want to draw</returns>
public Rect MakeXWidthRect(float x, float width)
{
if(width >= 0)
{
return new Rect(x, Y, width, Height);
}
return new Rect(x + width, Y, -width, Height);
}
After you draw your item, use return new HierarchyUsed(useRect); to tell the space you've used. Use return default if you don't draw this time.
public bool play;
[Range(0f, 1f)] public float range1;
[Range(0f, 1f)] public float range2;
private string ButtonLabel => play ? "Pause" : "Play";
#if UNITY_EDITOR
[HierarchyLeftButton("$" + nameof(ButtonLabel))]
private IEnumerator LeftBtn()
{
play = !play;
// ReSharper disable once InvertIf
if (play)
{
while (play)
{
range1 = (range1 + 0.0005f) % 1;
range2 = (range2 + 0.0009f) % 1;
EditorApplication.RepaintHierarchyWindow();
yield return null;
}
}
}
[HierarchyDraw("my progress bar")]
private HierarchyUsed DrawRight1G1(HierarchyArea headerArea)
{
Rect useRect = new Rect(headerArea.MakeXWidthRect(headerArea.GroupStartX - 40, 40))
{
height = headerArea.Height / 2,
};
Rect progressRect = new Rect(useRect)
{
width = range1 * useRect.width,
};
EditorGUI.DrawRect(useRect, Color.gray);
EditorGUI.DrawRect(progressRect, Color.red);
return new HierarchyUsed(useRect);
}
[HierarchyDraw("my progress bar")]
private HierarchyUsed DrawRight1G2(HierarchyArea headerArea)
{
Rect useRect = new Rect(headerArea.MakeXWidthRect(headerArea.GroupStartX - 40, 40))
{
y = headerArea.Y + headerArea.Height / 2,
height = headerArea.Height / 2,
};
Rect progressRect = new Rect(useRect)
{
width = range2 * useRect.width,
};
EditorGUI.DrawRect(useRect, Color.gray);
EditorGUI.DrawRect(progressRect, Color.yellow);
return new HierarchyUsed(useRect);
}
#endif
Comments
No comments yet. Be the first!
Sign in to join the conversation
Sign In