Skip to content

Commit

Permalink
Merge pull request #393 from Unity-Technologies/v4.5/backport-1332226…
Browse files Browse the repository at this point in the history
…-missing-gizmos-menu-items

[Backport] Fix for missing Gizmos Menu items for projects that have ProBuilder installed
  • Loading branch information
modrimkus authored Apr 30, 2021
2 parents 3766741 + a72f468 commit fe4e348
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Bug Fixes

- [case: 1332226] Fixed issue where some Gizmos menu items would be missing in projects that have ProBuilder package installed.

## [4.5.1] - 2021-02-04

### Bug Fixes
Expand Down
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 fe4e348

Please sign in to comment.