Skip to content

Commit

Permalink
Fix for missing Gizmos menu items in projects where ProBuilder packag…
Browse files Browse the repository at this point in the history
…e is installed
  • Loading branch information
modrimkus-unity committed Apr 29, 2021
1 parent 3766741 commit e6891f5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions Editor/EditorCore/HierarchyListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,7 @@ static class HierarchyListener
{
static HierarchyListener()
{
// The inspector icon for ProBuilderMesh is set in the component metadata. However, this also serves as the
// scene view gizmo icon, which we do not want. To avoid drawing an icon for every mesh in the Scene View,
// we simply tell the AnnotationManager to not render the icon. This _does_ put ProBuilderMesh in the
// "Recently Changed" list, but only when it is modified the first time.
// The alternative method of setting an icon is to place it in a folder named "Editor Default Resources/Icons",
// however that requires that the resources directory be in "Assets", which we do not want to do.
EditorUtility.SetGizmoIconEnabled(typeof(ProBuilderMesh), false);

AssemblyReloadEvents.afterAssemblyReload += OnAfterAssemblyReload;
// When a prefab is updated, this is raised. For some reason it's
// called twice?
#if UNITY_2018_1_OR_NEWER
Expand All @@ -33,6 +26,17 @@ static HierarchyListener()
PrefabUtility.prefabInstanceUpdated += PrefabInstanceUpdated;
}

static void OnAfterAssemblyReload()
{
// The inspector icon for ProBuilderMesh is set in the component metadata. However, this also serves as the
// scene view gizmo icon, which we do not want. To avoid drawing an icon for every mesh in the Scene View,
// we simply tell the AnnotationManager to not render the icon. This _does_ put ProBuilderMesh in the
// "Recently Changed" list, but only when it is modified the first time.
// The alternative method of setting an icon is to place it in a folder named "Editor Default Resources/Icons",
// however that requires that the resources directory be in "Assets", which we do not want to do.
EditorApplication.delayCall += () => EditorUtility.SetGizmoIconEnabled(typeof(ProBuilderMesh), false);
}

static void PrefabInstanceUpdated(GameObject go)
{
if (EditorApplication.isPlayingOrWillChangePlaymode)
Expand Down

0 comments on commit e6891f5

Please sign in to comment.