Optional automation for Editor tool developers. The namespace is ERAGANX.HierarchyOrganizerPro.Core; the assembly is ERAGANX.HierarchyOrganizerPro.Editor.
A complete selected-row command#
Save as ProjectHierarchyStyle.cs under your own Editor folder. Add an Editor assembly reference if your asmdef does not automatically reference the package. The example uses Unity selection to apply a Title recipe and reset selected own assignments.
#if UNITY_EDITOR
using UnityEditor;
using UnityEngine;
using ERAGANX.HierarchyOrganizerPro.Core;
public static class ProjectHierarchyStyle
{
[MenuItem("Tools/Project/Style Selected Group")]
private static void ApplyGroup()
{
var targets = Selection.gameObjects;
var style = new HierarchyStyle
{
role = StyleRole.Title,
kind = RowKind.Section,
bold = true,
backgroundEnabled = true,
background = new Color(0.27f, 0.48f, 0.77f),
opacity = 1f,
directCount = true,
childColorScope = ChildColorScope.Descendants,
childBackground = new Color(0.27f, 0.48f, 0.77f),
childOpacity = 0.18f
};
StyleCommands.ApplyTemplate(targets, style,
"Style selected project groups");
}
[MenuItem("Tools/Project/Reset Selected Row Styles")]
private static void ResetRows()
{
StyleCommands.Apply(Selection.gameObjects, null,
ApplyScope.Selection, "Reset selected styles");
}
}
#endifDownload ProjectHierarchyStyle.cs
Keep these references outside runtime assemblies/Player code. Commands filter non-editable targets and refuse row edits in Play Mode. Save scene identities and preserve metadata. The script follows inspected guide signatures; a newly added project's compilation/visual check remains its responsibility.
Public commands#
Prefer property edits when each row's unrelated choices should remain intact.
| Member | Use |
|---|---|
StyleResolver.Resolve(go) | Return resolved own/source/default style or null. Clone before direct customization. |
StyleCommands.Modify(...) | Modify(GameObject[], Action<HierarchyStyle>, ApplyScope = Selection, string action): edit chosen properties. |
StyleCommands.Apply(...) | Apply(GameObject[], HierarchyStyle, ApplyScope, string action): copy a complete style; null resets own assignments. |
StyleCommands.ApplyTemplate(...) | ApplyTemplate(GameObject[], HierarchyStyle, string action): apply full template and explicit child-color recipe. |
StyleCommands.ModifyGroup(...) | ModifyGroup(GameObject[], Action<HierarchyStyle>, bool applyChildColors, string action): property editing with optional child painting. |
ClearChildColors(selected) | Clear backgrounds within selected groups' remembered child-color scope. |
Copy(go) / ReadClipboard() | Write/read package style payload; invalid clipboard returns null. |
ApplyPrefabSource(go) | Assign resolved style to corresponding prefab source after customizing the object. |
PresetLibrary | Factory, All, Find; SaveCustom, SaveCopy, Update, Rename, Delete; Export, Parse, ImportFile. |
HierarchyStyle.Clone / Normalize | Clone shared data before edits; Normalize validates enums/ranges and derives horizontal gradient. |
Preserve independent row choices#
// In Editor code with the package and UnityEditor namespaces imported:
StyleCommands.Modify(Selection.gameObjects,
s => { s.bold = true; s.uppercase = true; },
ApplyScope.Selection, "Emphasize selected rows");Scope enums#
| ApplyScope | Targets |
|---|---|
| Selection | Selected target rows only. |
| DirectChildren | Immediate children, excluding roots. |
| Descendants | All children, excluding roots. |
| Subtree | Roots and all descendants. |
ChildColorScope has None, DirectChildren and Descendants. This controls explicit background painting, separate from full-style command scope and prefab-source inheritance.