private static void HandleWindowsGUI(SceneView sceneView) { if (SceneViewGUIWindowHandler.RenderWindows(Event.current)) { SceneView.RepaintAll(); } }
public static void UpdateMouseOverPrimitives(Event current, bool forced = false) { // Can't perform picking during repaint event. if (current == null || !(current.isMouse || current.isKey || forced)) { return; } // Update mouse over before we reveal the VisualPrimitives. // NOTE: We're putting our "visual primitives" in the ignore list. if (current.isMouse || forced) { var ignoreList = new List <GameObject>(); foreach (var primitive in m_visualPrimitives) { if (!primitive.Visible) { continue; } var primitiveFilters = primitive.Node.GetComponentsInChildren <MeshFilter>(); ignoreList.AddRange(primitiveFilters.Select(pf => { return(pf.gameObject); })); } // If the mouse is hovering a scene view window - MouseOverObject should be null. if (SceneViewGUIWindowHandler.GetMouseOverWindow(current.mousePosition) != null) { MouseOverObject = null; } else { MouseOverObject = RouteObject(HandleUtility.PickGameObject(current.mousePosition, false, ignoreList.ToArray())) as GameObject; } } // Early exit if we haven't any active visual primitives. if (m_visualPrimitives.Count == 0) { return; } var primitiveHitList = new[] { new { Primitive = (Utils.VisualPrimitive)null, RaycastResult = Utils.Raycast.Result.Invalid } }.ToList(); primitiveHitList.Clear(); var mouseRay = HandleUtility.GUIPointToWorldRay(current.mousePosition); foreach (var primitive in m_visualPrimitives) { primitive.MouseOver = false; if (!primitive.Pickable) { continue; } var result = Utils.Raycast.Intersect(mouseRay, primitive.Node, true); if (result) { primitiveHitList.Add(new { Primitive = primitive, RaycastResult = result }); } } if (primitiveHitList.Count == 0) { return; } var bestResult = primitiveHitList[0]; for (int i = 1; i < primitiveHitList.Count; ++i) { if (primitiveHitList[i].RaycastResult.Distance < bestResult.RaycastResult.Distance) { bestResult = primitiveHitList[i]; } } bestResult.Primitive.MouseOver = true; if (HijackLeftMouseClick()) { bestResult.Primitive.OnMouseClick(bestResult.RaycastResult, bestResult.Primitive); } }