title: Using Unity3D's IPointerDownHandler approach, but with "the whole screen"
body: <p>In Unity say you need to detect finger touch (finger drawing) on something in the scene.</p>
  
  <p>The only way to do this <strong>in modern Unity, is very simple</strong>:</p>
  
  <hr>
  
  <p><strong>Step 1</strong>. Put a collider on that object. ("The ground" or whatever it may be.) <sup>1</sup></p>
  
  <p><strong>Step 2.</strong> On your camera, Inspector panel, click to add a Physics Raycaster (2D or 3D as relevant).</p>
  
  <p><strong>Step 3.</strong> Simply use code as in Example A below.</p>
  
  <p><em>(Tip - don't forget to ensure there's an EventSystem ... sometimes Unity adds one automatically, sometimes not!)</em></p>
  
  <hr>
  
  <p>Fantastic, couldn't be easier. Unity finally handles un/propagation correctly through the UI layer.  Works uniformly and flawlessly on desktop, devices, Editor, etc etc. Hooray Unity.</p>
  
  <p>All good. But what if you want to draw just <strong>"on the screen"</strong>?</p>
  
  <p>So you are wanting, quite simply, swipes/touches/drawing from the user "on the screen".   (Example, simply for operating an orbit camera, say.) So just as in any ordinary 3D game where the camera runs around and moves.</p>
  
  <p>You don't want the position of the finger on <strong>some object</strong> in world space, you simply want abstract "finger motions" (i.e. position on the glass).</p>
  
  <p>What collider do you then use? Can you do it with no collider?  It seems fatuous to add a collider just for that reason.</p>
  
  <p><strong>What we do is this</strong>:</p>
  
  <p>I just make a flat collider of some sort, and actually attach it <strong>under the camera</strong>.  So it simply sits in the camera frustum and completely covers the screen.</p>
  
  <p><a href="https://i.stack.imgur.com/wQOv4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wQOv4.png" alt="enter image description here"></a></p>
  
  <p>(For the code, there is then no need to use ScreenToWorldPoint, so just use code as in Example B - extremely simple, works perfectly.)</p>
  
  <p>My question, it seems a bit odd to have to use the "under-camera colldier" I describe, just to get touches on the glass.</p>
  
  <p>What's the deal here?</p>
  
  <p>(Note -  please don't answer involving Unity's ancient "Touches" system, which is unusable today for real projects, you can't ignore .UI using the legacy approach.)</p>
  
  <hr>
  
  <p>Code sample A - drawing on a scene object. Use ScreenToWorldPoint.</p>
  
  <pre><code> using UnityEngine;
   using System.Collections;
   using UnityEngine.EventSystems;
  
   public class FingerMove:MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
   {
       public void OnPointerDown (PointerEventData data)
       {
           Debug.Log("FINGER DOWN");
           prevPointWorldSpace =
                   theCam.ScreenToWorldPoint( data.position );
       }
  
       public void OnDrag (PointerEventData data)
       {
           thisPointWorldSpace =
                  theCam.ScreenToWorldPoint( data.position );
           realWorldTravel =
                  thisPointWorldSpace - prevPointWorldSpace;
           _processRealWorldtravel();
           prevPointWorldSpace = thisPointWorldSpace;
       }
  
       public void OnPointerUp (PointerEventData data)
       {
           Debug.Log("clear finger...");
       }
  </code></pre>
  
  <p>Code sample B ... you only care about what the user does on the glass screen of the device.  Even easier here:</p>
  
  <pre><code> using UnityEngine;
   using System.Collections;
   using UnityEngine.EventSystems;
  
   public class FingerMove:MonoBehaviour, IPointerDownHandler, IDragHandler, IPointerUpHandler
   {
       private Vector2 prevPoint;
       private Vector2 newPoint;
       private Vector2 screenTravel;
  
       public void OnPointerDown (PointerEventData data)
       {
           Debug.Log("FINGER DOWN");
           prevPoint = data.position;
       }
  
       public void OnDrag (PointerEventData data)
       {
           newPoint = data.position;
           screenTravel = newPoint - prevPoint;
           prevPoint = newPoint;
           _processSwipe();
       }
  
       public void OnPointerUp (PointerEventData data)
       {
           Debug.Log("FINEGR UP...");
       }
  
       private void _processSwipe()
       {
           // your code here
           Debug.Log("screenTravel left-right.. " + screenTravel.x.ToString("f2"));
       }
   }
  </code></pre>
  
  <hr>
  
  <p><sup>1</sup> If you're just new to Unity: at that step very likely, make it a layer called say "Draw"; in physics settings make "Draw" interact with nothing; in step two with the Raycaster just set the layer to "Draw".</p>