Author Topic: Touches and Event System  (Read 1817 times)

Zophiel

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 54
    • View Profile
Touches and Event System
« on: December 05, 2012, 05:36:17 PM »
Hello,

I've been reading several threads on the NGUI event system but i'm unsure how to set it up correctly with multi touches. If i got this right i need to at least attached an instance of UICamera to my main game camera. But how do i convert the following code to correctly use the NGUi events?

  1. //Touch and drag
  2. if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved)
  3. //Pinch to zoom
  4. if (Input.touchCount > 1 && (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved))

Reason being that when i press a button in my scene the camera reacts to it.

Cheers

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Touches and Event System
« Reply #1 on: December 05, 2012, 06:21:49 PM »
You don't. You create functions -- OnPress, OnDrag, etc -- and write your logic inside. You can check what touch it is via UICamera.currentTouchID.