<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Infinity Code Forum — Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
	<link rel="self" href="https://forum.infinity-code.com/extern.php?action=feed&amp;tid=108&amp;type=atom" />
	<updated>2016-03-16T19:12:54Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.infinity-code.com/viewtopic.php?id=108</id>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=484#p484" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T19:12:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=484#p484</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=483#p483" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T19:05:44Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=483#p483</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=482#p482" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T19:04:01Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=482#p482</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=481#p481" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2016-03-16T18:04:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=481#p481</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=480#p480" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2016-03-16T17:50:13Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=480#p480</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=478#p478" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T17:22:35Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=478#p478</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=476#p476" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Alex Vertax]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=2</uri>
			</author>
			<updated>2016-03-16T16:55:54Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=476#p476</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=475#p475" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T16:21:04Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=475#p475</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Android/Samsung Tablet: NGUI Texture, first touch not firing events]]></title>
			<link rel="alternate" href="https://forum.infinity-code.com/viewtopic.php?pid=470#p470" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[stephen]]></name>
				<uri>https://forum.infinity-code.com/profile.php?id=99</uri>
			</author>
			<updated>2016-03-16T07:09:27Z</updated>
			<id>https://forum.infinity-code.com/viewtopic.php?pid=470#p470</id>
		</entry>
</feed>
