Skip to content

Feature: highlights scene items #116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions HierarchyDecorator/Scripts/Editor/Data/HierarchyStyleData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public Color GetColor(Rect rect)
}
}

[System.Serializable]
public class SceneItemHighlightSettings
{
public Color color = new Color(0.25f, 1.0f, 0.25f, 0.2f);
[Min(0)] public int lineThickness = 17;
[Min(0)] public int lineWidth = 34;
}

[System.Serializable]
public class HierarchyStyleData
{
Expand Down Expand Up @@ -99,6 +107,12 @@ public class HierarchyStyleData
public ColorSetting lightMode = new ColorSetting(new Color(0.8f, 0.8f, 0.8f, 1f), new Color(0.765f, 0.765f, 0.765f, 1f));
public ColorSetting darkMode = new ColorSetting(new Color(0.245f, 0.245f, 0.245f, 1f), new Color(0.225f, 0.225f, 0.225f, 1f));

// Scene Item Highlight
public bool showSceneItemHighlight = true;
public SceneItemHighlightSettings sceneItemHighlight = new SceneItemHighlightSettings();

// Background

// --- Methods

// Styles
Expand Down
21 changes: 20 additions & 1 deletion HierarchyDecorator/Scripts/Editor/HierarchyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public static void OnGUI(int id, Rect rect)

if (!TryGetValidInstance(id, out HierarchyItem item))
{
DrawSceneItemHighlight(rect, id);
return;
}

Expand Down Expand Up @@ -160,6 +161,24 @@ private static HierarchyItem GetNext(int id, GameObject instance)
return item;
}

private static void DrawSceneItemHighlight(Rect rect, int id)
{
if (!s_Settings.styleData.showSceneItemHighlight)
return;
for (int i = 0; i < SceneManager.sceneCount; ++i)
{
var scene = SceneManager.GetSceneAt(i);
if (scene.GetHashCode() == id)
{
rect.x -= 48;
rect.width = s_Settings.styleData.sceneItemHighlight.lineWidth;
rect.height = s_Settings.styleData.sceneItemHighlight.lineThickness;
EditorGUI.DrawRect(rect, s_Settings.styleData.sceneItemHighlight.color);
break;
}
}
}

public static bool IsPreviousParent()
{
if (Previous == null)
Expand Down Expand Up @@ -232,4 +251,4 @@ public IEnumerable<ComponentItem> GetItems()
}
}
}
}
}
10 changes: 8 additions & 2 deletions HierarchyDecorator/Scripts/Editor/Tabs/StyleTab.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ public StyleTab(Settings settings, SerializedObject serializedSettings) : base (
CreateDrawableGroup("Background")
.RegisterSerializedProperty(serializedTab, "twoToneBackground")
.RegisterSerializedGroup(darkModeBack, "Dark Mode", "colorOne", "colorTwo")
.RegisterSerializedGroup(lightModeBack, "Light Mode", "colorOne", "colorTwo");
.RegisterSerializedGroup(lightModeBack, "Light Mode", "colorOne", "colorTwo").Space()
.RegisterSerializedProperty(serializedTab, "showSceneItemHighlight")
.RegisterSerializedGroup(serializedTab.FindPropertyRelative("sceneItemHighlight"),
"Highlight Settings",
nameof(SceneItemHighlightSettings.color),
nameof(SceneItemHighlightSettings.lineWidth),
nameof(SceneItemHighlightSettings.lineThickness));

CreateDrawableGroup ("Styles")
.RegisterSerializedProperty(serializedTab, "displayTags", "displayLayers", "displayIcons")
Expand Down Expand Up @@ -400,4 +406,4 @@ private Rect GetElementDeleteRect(Rect rect)
return rect;
}
}
}
}