<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — OnGetInputPosition from RawImageTouchForwarder returns Vector2.zero]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=2428&amp;type=atom" />
	<updated>2026-07-23T12:07:43Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=2428</id>
		<entry>
			<title type="html"><![CDATA[Re: OnGetInputPosition from RawImageTouchForwarder returns Vector2.zero]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9990#p9990" />
			<content type="html"><![CDATA[<p>Hi,</p><p>Try commenting out the following line in OnlineMapsRawImageTouchForwarder.OnEnable:</p><div class="codebox"><pre><code>control.checkScreenSizeForWheelZoom = false;</code></pre></div><p>Unfortunately, since this code was written quite a long time ago, I no longer remember exactly why I disabled this option there.</p>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2026-07-23T12:07:43Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9990#p9990</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[OnGetInputPosition from RawImageTouchForwarder returns Vector2.zero]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=9989#p9989" />
			<content type="html"><![CDATA[<p>I&#039;m using Online Maps 3.10.1.1</p><p>This code is from OnlineMapsRawImageTouchForwarder:</p><div class="codebox"><pre><code>    private Vector2 OnGetInputPosition()
    {
        if (target != image.gameObject) return Vector2.zero;
        return ProcessTouch(pointerPos, out Vector2 pos) ? pos : Vector2.zero;
    }</code></pre></div><p>If target is not image.gameObject it return Vector2.zero. Target is taken from this method:</p><div class="codebox"><pre><code>private GameObject GetTargetGameObject(Vector2 position)
{
    PointerEventData pe = new PointerEventData(EventSystem.current)
    {
        position = position
    };

    List&lt;RaycastResult&gt; hits = new List&lt;RaycastResult&gt;();
    EventSystem.current.RaycastAll(pe, hits);

    if (hits.Count == 0) return null;

    return hits[0].gameObject;
}</code></pre></div><p>Meaning if we dont hit anything it returns Vector2.zero, meaning if in unity editor mouse is outside game tab and we use mouse scroll wheel map will zoom. How can I prevent that zoom? I&#039;ve tried to change the OnGetInputPosition method to return Vector2.positiveInfinity, but them I&#039;m getting exceptions &quot;Screen position out of view frustrum&quot; from within Online maps code on android build.</p><p>This is the UpdateZoom method which uses the OnGetInputPosition:<br /></p><div class="codebox"><pre><code>    protected void UpdateZoom()
    {
#if (UNITY_IOS || UNITY_ANDROID) &amp;&amp; !UNITY_EDITOR
        return;
#else
        
        if (!HitTest()) return;

        Vector2 inputPosition = GetInputPosition();

        if (IsCursorOnUIElement(inputPosition)) return;

        if (checkScreenSizeForWheelZoom &amp;&amp; (inputPosition.x &lt;= 0 || inputPosition.x &gt;= Screen.width || inputPosition.y &lt;= 0 || inputPosition.y &gt;= Screen.height)) return;

        float wheel = OnlineMapsInput.GetAxis(&quot;Mouse ScrollWheel&quot;);
        if (Math.Abs(wheel) &lt; float.Epsilon) return;

#if NETFX_CORE
        wheel = -wheel;
#endif

        float delta = wheel &gt; 0 ? zoomSpeed : -zoomSpeed;
        if (OnValidateZoom == null || OnValidateZoom(OnlineMapsZoomEvent.wheel, map.floatZoom + delta))
        {
            if (zoomMode == OnlineMapsZoomMode.target) ZoomOnPoint(delta, inputPosition);
            else map.floatZoom += delta;
        }
#endif
    }</code></pre></div><p>How can I handle this? Thanks for help.</p>]]></content>
			<author>
				<name><![CDATA[mikli1]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2745</uri>
			</author>
			<updated>2026-07-23T11:27:05Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=9989#p9989</id>
		</entry>
</feed>
