<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Infinity Code Forum — Allow zooming in Editor when mouse is over UI element]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=1862</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=1862&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Allow zooming in Editor when mouse is over UI element.]]></description>
		<lastBuildDate>Fri, 29 Oct 2021 18:18:47 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Allow zooming in Editor when mouse is over UI element]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7838#p7838</link>
			<description><![CDATA[<p>Hello.</p><p>Something like that:<br /></p><div class="codebox"><pre><code>using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

#if UNITY_EDITOR
public class AllowZoomOnGUI : MonoBehaviour
{
    private OnlineMaps map;

    private void Start()
    {
        map = OnlineMaps.instance;
        map.notInteractUnderGUI = false;
        map.control.OnMapPress += OnMapPress;
    }

    public bool IsCursorOnUIElement(Vector2 position)
    {
        if (GUIUtility.hotControl != 0) return true;
        if (EventSystem.current == null) return false;

        PointerEventData pe = new PointerEventData(EventSystem.current);
        pe.position = position;

        List&lt;RaycastResult&gt; hits = new List&lt;RaycastResult&gt;();
        EventSystem.current.RaycastAll(pe, hits);
        if (hits.Count == 0) return false;

        GameObject go = hits[0].gameObject;
        if (go == gameObject) return false;

        return go.GetComponent&lt;OnlineMapsMarkerInstanceBase&gt;() == null &amp;&amp; go.GetComponent&lt;OnlineMapsBuildingBase&gt;() == null;
    }

    private void OnMapPress()
    {
        if (IsCursorOnUIElement(map.control.GetInputPosition()))
        {
            map.control.OnUpdateAfter += CancelMapDrag;
        }
    }

    private void CancelMapDrag()
    {
        map.control.OnUpdateAfter -= CancelMapDrag;
        map.control.isMapDrag = false;
    }
}
#endif</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Fri, 29 Oct 2021 18:18:47 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7838#p7838</guid>
		</item>
		<item>
			<title><![CDATA[Allow zooming in Editor when mouse is over UI element]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=7836#p7836</link>
			<description><![CDATA[<p>Currently one can only disable the ControlBase completely using the notInteractUnderGUI flag. Me personally I would like to disable dragging the camera when the input started on a UI element, but allow zooming when the user uses the mouse in the editor and the cursor is currently over a UI element. Cheers</p>]]></description>
			<author><![CDATA[null@example.com (negruj0w1tsch)]]></author>
			<pubDate>Fri, 29 Oct 2021 14:57:37 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=7836#p7836</guid>
		</item>
	</channel>
</rss>
