From 8cde10d10a62e20ddfdc65723c941df413a0b081 Mon Sep 17 00:00:00 2001 From: Ramon Brullo Date: Tue, 5 Nov 2024 16:20:12 +0100 Subject: [PATCH] fix: bad selection logic Previously there was a bug where the material was always applied to the first game-object in the hierarchy, instead of the hovered one. Now this is fixed. --- Code/ApplyMaterialToAll.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Code/ApplyMaterialToAll.cs b/Code/ApplyMaterialToAll.cs index cec848a..11d0624 100644 --- a/Code/ApplyMaterialToAll.cs +++ b/Code/ApplyMaterialToAll.cs @@ -22,10 +22,14 @@ public static class ApplyMaterialToAll private static void OnHierarchyGUI(int instanceID, Rect selectionRect) { var currentEvent = Event.current; - + // Must hold alt if (!currentEvent.alt) return; + // Must be hovering selection rect + if (!selectionRect.Contains(currentEvent.mousePosition)) return; + + // Must only drag single material if (TryGetDraggedMaterial() is not { } material) return;