Author Topic: Problems with Draggable Camera  (Read 9001 times)

Bobbin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Problems with Draggable Camera
« on: December 24, 2013, 02:56:52 AM »
I'm trying to use the Draggable Camera by calling for it within my own script.

For a simple drag, I use the OnDrag method in my script with a collider and pass the delta off to draggable camera, adding the Press(true) before and Press(false) after.
But this causes a jump as the drag passes the drag threshold. However, when I set for a smooth drag start, drag doesn't even start. And I can't seem to find what calls it to start or where the threshold is exactly.

Also, when I try to do a different drag, both the regular drag and my different drag are called at the same time, causing it to move much quicker.

I'm asking here because I've spent several days trying to find any help or tutorial on how to do what I'm trying to do. Any help will be appreciated.

Thanks.
No one ever said being a Heretic was easy.
So may we meet in Less Interesting Times.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with Draggable Camera
« Reply #1 on: December 24, 2013, 12:59:59 PM »
First... why are you doing this, and second -- why are you using the draggable camera script? It's meant for scroll views in cases where shader support is not available. Since Unity no longer supports devices that can't support shaders, this script is also no longer needed. I've been considering removing it along with the camera-based scroll view example for the next release, actually.

Bobbin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Problems with Draggable Camera
« Reply #2 on: December 25, 2013, 04:47:38 AM »
I'm doing this because, for several reasons, I need to reroute touch gestures through my own script.

Basically, I need my script to sit between the touch events and the camera but still function with regular drag and pinch zoom. Do you have a better idea how I can facilitate drag and pinch zoom?
No one ever said being a Heretic was easy.
So may we meet in Less Interesting Times.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with Draggable Camera
« Reply #3 on: December 25, 2013, 03:24:48 PM »
UICamera.genericEventHandler will receive a copy of all events, if set. Set it to your touch manager game object, and do gesture recognition in a script attached to that object using normal NGUI events -- OnPress, OnDrag, etc.

Bobbin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Problems with Draggable Camera
« Reply #4 on: December 26, 2013, 02:31:26 AM »
So, if I get this right: ditch the draggable camera, set my object as the generic event handler and handle events all by myself, moving the camera and zooming in and out in my script, right?

Will this still work if I have one camera that views the world and handles dragging and zoom and another that renders the HUD and responds to specific HUD click events?
No one ever said being a Heretic was easy.
So may we meet in Less Interesting Times.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Problems with Draggable Camera
« Reply #5 on: December 26, 2013, 06:43:44 PM »
Yes, just like that. Just keep in mind you won't be handling events, you'll be reacting to NGUI events.

Generic event handler gets events regardless of whether they were handled by some other camera or not. If you want only events that fell through everything, use UICamera.fallThrough instead. Just keep in mind that for this to work as you'd expect you would need to have the lowest depth camera (usually your main camera) not have its drawn objects intercept events -- which means having no UICamera on it, or UICamera set to event mask of "nothing".

Bobbin

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: Problems with Draggable Camera
« Reply #6 on: December 29, 2013, 02:28:34 AM »
Ok. Thanks.
No one ever said being a Heretic was easy.
So may we meet in Less Interesting Times.