diff --git a/CHANGELOG.md b/CHANGELOG.md index e9e2dae..c6032b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 mode) - [#441] Fixed an issue where the preview object pickable status could get out of sync with the original - [#444] Fixed an issue where the preview system broke drag-and-drop of materials onto the scene view +- [#444] Fixed an issue where the preview system broke drag-to-select in the scene view ### Changed - [#451] Changed preview system to apply to more cameras. Specifically, we now handle all cameras with no render diff --git a/Editor/Harmony/HandleUtilityPatches.cs b/Editor/Harmony/HandleUtilityPatches.cs index 4485b55..c00468f 100644 --- a/Editor/Harmony/HandleUtilityPatches.cs +++ b/Editor/Harmony/HandleUtilityPatches.cs @@ -92,6 +92,15 @@ internal static void Patch_FilterInstanceIDs(Harmony h) new HarmonyMethod(m_prefix_internal_getclosestpickingid), new HarmonyMethod(m_postfix_internal_getclosestpickingid) ); + + var m_internal_pickrectobjects = AccessTools.Method(t_HandleUtility, "Internal_PickRectObjects"); + var m_postfix_internal_pickrectobjects = AccessTools.Method(typeof(HandleUtilityPatches), + nameof(Postfix_Internal_PickRectObjects)); + + h.Patch( + m_internal_pickrectobjects, + postfix: new HarmonyMethod(m_postfix_internal_pickrectobjects) + ); } private static readonly Type ty_PickingObject = AccessTools.TypeByName("UnityEditor.PickingObject"); @@ -167,6 +176,29 @@ ref uint __result } } + [UsedImplicitly] + private static void Postfix_Internal_PickRectObjects( + Camera cam, + Rect rect, + bool selectPrefabRoots, + bool drawGizmos, + ref GameObject[] __result + ) + { + if (__result == null) return; + + var sess = PreviewSession.Current; + if (sess == null) return; + + for (var i = 0; i < __result.Length; i++) + { + if (sess.ProxyToOriginalObject.TryGetValue(__result[i], out var original) && original != null) + { + __result[i] = original; + } + } + } + [UsedImplicitly] private static bool Prefix_FilterInstanceIDs( ref IEnumerable gameObjects,