Simple Touch Input


/ Published in: C#
Save to your folder(s)

Simple touch detection in unity for mob devices


Copy this code and paste it in your HTML
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class OnTouchDown : MonoBehaviour {
  5.  
  6. foreach (Touch touch in Input.touches)
  7. {
  8. if (touch.phase == TouchPhase.Began)
  9. {
  10. // do staff when user just touch
  11. }
  12. else if (touch.phase == TouchPhase.Ended)
  13. {
  14. // do staff when user touch ended
  15. }
  16. }
  17.  
  18. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.