Skip to content

Override Notification (TTB) Bug Fix #113

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 1 commit 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System.Collections.Generic;
using UnityEditor.SceneManagement;
using UnityEditor;
using UnityEngine;

namespace HierarchyDecorator
{
public class PrefabOverrideDrawer : HierarchyDrawer
{
protected override bool DrawerIsEnabled(HierarchyItem item, Settings settings) => settings.styleData.twoToneBackground && PrefabStageUtility.GetCurrentPrefabStage() == null;

protected override void DrawInternal(Rect rect, HierarchyItem item, Settings _settings)
{
rect.width = 2;

#if UNITY_2019_1_OR_NEWER
rect.x = 32;
#else
rect.x = 1f;
rect.y--;
#endif

GameObject instance = item.GameObject;

//Draw the little bar that indicates there's modifications in your prefab instance.
DrawPrefabOverrideBar(rect, instance);
}

private void DrawPrefabOverrideBar(Rect rect, GameObject instance)
{
PrefabInstanceStatus status = PrefabUtility.GetPrefabInstanceStatus(instance);
if (status == PrefabInstanceStatus.Connected)
{
bool condition = false;
#if UNITY_2018_3_OR_NEWER
condition = PrefabUtility.GetObjectOverrides(instance).Count > 0;
#else
condition = PrefabUtility.GetPropertyModifications(instance).Count > 0;
#endif
if (condition) EditorGUI.DrawRect(rect, Color.cyan);
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion HierarchyDecorator/Scripts/Editor/HierarchyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static class HierarchyManager
{
new StateDrawer(),
new ToggleDrawer(),
new BreadcrumbsDrawer()
new BreadcrumbsDrawer(),
new PrefabOverrideDrawer()
};

private static HierarchyInfo[] Info = new HierarchyInfo[]
Expand Down