<?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 — Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
		<link>https://forum.infinity-code.com/viewtopic.php?id=108</link>
		<atom:link href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=108&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[The most recent posts in Android/Samsung Tablet: NGUI Texture, first touch not firing events.]]></description>
		<lastBuildDate>Wed, 16 Mar 2016 19:12:54 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=484#p484</link>
			<description><![CDATA[<p>Confirmed the new code works perfectly on an Android build deployed to my tablet.</p><p>When run through the editor using Unity Remote to connect to the tablet, it does the same thing as before--you can&#039;t drag the map until you manually click on the map once in the Unity Editor Game window (as expected with the code as it stands).</p><p>For testing purposes&nbsp; in my build I&#039;m going to make it just</p><div class="codebox"><pre><code>#if (UNITY_ANDROID || UNITY_IOS)</code></pre></div><p>for now, since Unity Remote is a pretty useful testing tool for me.</p><p>Thanks much for the confirmation and fix!</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 19:12:54 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=484#p484</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=483#p483</link>
			<description><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>I found a way to fix it.</p><p>OnlineMapsNGUITextureControl.cs<br /></p><div class="codebox"><pre><code>    protected override bool HitTest()
    {
#if (UNITY_ANDROID || UNITY_IOS) &amp;&amp; !UNITY_EDITOR
        return UICamera.currentTouch != null &amp;&amp; UICamera.currentTouch.current == gameObject;
#else
        return UICamera.hoveredObject == gameObject;
#endif
    }</code></pre></div></blockquote></div><p>Looks good, thanks!</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 19:05:44 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=483#p483</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=482#p482</link>
			<description><![CDATA[<div class="quotebox"><cite>Alex Vertax wrote:</cite><blockquote><p>I do not know what is «CROSS PLATFORM INPUT» and «MOBILE_INPUT».<br />This is from some third-party asset?<br />Online Maps and NGUI not require those directives.</p></blockquote></div><p>They were added to the Build Settings by Unity when I selected the Android build target.</p><p>CROSS_PLATFORM_INPUT I think is something new with Unity 5...not sure where MOBILE_INPUT came from myself.</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 19:04:01 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=482#p482</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=481#p481</link>
			<description><![CDATA[<p>I found a way to fix it.</p><p>OnlineMapsNGUITextureControl.cs<br /></p><div class="codebox"><pre><code>    protected override bool HitTest()
    {
#if (UNITY_ANDROID || UNITY_IOS) &amp;&amp; !UNITY_EDITOR
        return UICamera.currentTouch != null &amp;&amp; UICamera.currentTouch.current == gameObject;
#else
        return UICamera.hoveredObject == gameObject;
#endif
    }</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 16 Mar 2016 18:04:35 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=481#p481</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=480#p480</link>
			<description><![CDATA[<p>I do not know what is «CROSS PLATFORM INPUT» and «MOBILE_INPUT».<br />This is from some third-party asset?<br />Online Maps and NGUI not require those directives.</p>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 16 Mar 2016 17:50:13 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=480#p480</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=478#p478</link>
			<description><![CDATA[<p>It does sound like a bug on their side, I&#039;d agree.</p><p>It&#039;s also possible I have an unusual set of defines...as you know I&#039;m still new to Unity in general, and this is my first Android build attempt...I didn&#039;t myself add anything except NGUI to the Symbol defines--Unity did the rest...but is it the right set of defines?</p><p>Build Settings -&gt; Player Settings -&gt; Scripting Define Symbols: CROSS_PLATFORM_INPUT;MOBILE_INPUT;NGUI</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 17:22:35 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=478#p478</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=476#p476</link>
			<description><![CDATA[<p>Hello.</p><p>Yes, I too have found this line.<br />Use compilation directive is a possible solution.<br />But I want to understand why this is happening.<br />We do not use it correctly, or is it a bug in NGUI.</p><p>NGUI API Reference:<br /></p><div class="codebox"><pre><code>/// &lt;summary&gt;
/// The object over which the mouse is hovering over, or the object currently selected by the controller input.
/// Mouse and controller input share the same hovered object, while touches have no hovered object at all.
/// Checking this value from within a touch-based event will simply return the current touched object.
/// &lt;/summary&gt;

static public GameObject hoveredObject</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (Alex Vertax)]]></author>
			<pubDate>Wed, 16 Mar 2016 16:55:54 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=476#p476</guid>
		</item>
		<item>
			<title><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=475#p475</link>
			<description><![CDATA[<p>Found the problem:</p><p>OnlineMapsControlBase.cs:<br /></p><div class="codebox"><pre><code>    protected void OnMapBasePress()
    {
        if (waitZeroTouches)
        {
            if (Input.touchCount &lt;= 1) waitZeroTouches = false;
            else return;
        }

        dragMarker = null;
        if (!HitTest()) return;  // test to see if map is under the interaction point</code></pre></div><p>OnlineMapsNGUITextureControl.cs:<br /></p><div class="codebox"><pre><code>    protected override bool HitTest()
    {
        return UICamera.hoveredObject == gameObject; 
        // assumes mouse pointer is hovering over map object...but no mouse pointer on tablets
    }</code></pre></div><p>UICamera.hoveredObject is always null on my tablet (no concept of hovering I assume since there is no mouse cursor).</p><p>Once you click on the Game Window (under Unity Remote), UICamera.hoveredObject becomes the map object (and never changes), so the if (!HitTest()) return; call starts succeeding, and the rest of the events are processed.</p><p>I&#039;m guessing we need to do an #ifdef for mobile devices, and have an alternate test for clicking on the map?</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 16:21:04 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=475#p475</guid>
		</item>
		<item>
			<title><![CDATA[Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link>https://forum.infinity-code.com/viewtopic.php?pid=470#p470</link>
			<description><![CDATA[<p>Unity 5.3.2f1, Online Maps latest stable<br />Android Build, Samsung&nbsp; SM-P900 Table (Note 2)<br />Online Maps NGUI Texture Control, no additional components<br />Build Symbol Defines: CROSS_PLATFORM_INPUT;NGUI<br />--same issue with both MOBILE_INPUT defined, and not defined</p><p>Additional Info: <br />Allow Add Marker : OFF<br />Allow Zoom: ON<br />Allow User Control: ON<br />Invert Touch Zoom: OFF<br />Zoom In On Double Click: OFF</p><p>I was testing an Android build/deploy of my app, and discovered that I could not drag the map, but I could pinch-zoom (so input events in general are working). Build was generated using BUILD AND RUN of the Android target to a USB connected device.</p><p>I could press my markers as expected, as well as other NGUI objects, so press events in general are working.</p><p>Further troubleshooting using Unity Remote 4, Unity Editor and Debug.log to catch events, I determined that at least two events were not firing during user input on the map:</p><p>OnlineMapsControlBase.instance.OnMapPress += OnMapPress; &lt;-- would not fire<br />OnlineMapsControlBase.instance.OnMapDrag += OnMapDrag; &lt;-- would not fire<br />OnlineMapsControlBase.instance.OnMapRelease += OnMapRelease; &lt;-- fired as expected</p><p>I used the following to test the events firing/not firing:<br /></p><div class="codebox"><pre><code>public class OverlandMap : MonoBehaviour {

    void OnMapPress()
    {
        Debug.Log(&quot;OverlandMap--onMapPress fired&quot;);
    }

    void OnMapRelease()
    {
        Debug.Log(&quot;OverlandMap--onMapRelease fired&quot;);
    }

    void OnMapDrag()
    {
        Debug.Log(&quot;OverlandMap--onMapDrag fired&quot;);
    }
    // Use this for initialization
    void Start () {
        OnlineMapsControlBase.instance.OnMapPress += OnMapPress;
        OnlineMapsControlBase.instance.OnMapRelease += OnMapRelease;
        OnlineMapsControlBase.instance.OnMapDrag += OnMapDrag;
   }
}</code></pre></div><p>By random chance, I clicked on the Unity Editor Game window while the build was still running, and saw the OnMapPress event fire in my Console. I then went back to my tablet, and all events were working as normal--they fired in the Console window, and the map scrolled normally (via drag gesture). This is reproduceable--it happens every run.</p><p>Obviously I can&#039;t click on the game window when running an app native build (outside of Unity Remote/Unity Editor), but I&#039;m pretty sure the same will happen.</p><p>To make sure it wasn&#039;t my error somewhere, I then used a basic project with a simple NGUI Texture map and was able to duplicate.</p><p>I did try some troubleshooting with VS 2015 attached as debugger, and confirmed that OnlineMapsControlBase::OnMapBasePress() was being called, but quickly got lost in the camera/map event processing code.</p><p>Please let me know if you need any additional information or troubleshooting assistance.</p>]]></description>
			<author><![CDATA[null@example.com (stephen)]]></author>
			<pubDate>Wed, 16 Mar 2016 07:09:27 +0000</pubDate>
			<guid>https://forum.infinity-code.com/viewtopic.php?pid=470#p470</guid>
		</item>
	</channel>
</rss>
