Author Topic: OnDragRelease Problem: Surface is NEVER detected  (Read 1879 times)

Ace

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 24
    • View Profile
OnDragRelease Problem: Surface is NEVER detected
« on: August 04, 2014, 05:51:32 PM »
Greetings,

I've been looking at example 11 all day. Its where you can drag UI elements on to 3D objects and create a pre-fab on them.

I slimmed the whole thing down to just a draggable icon, and the box to drop it on. All works.

Change over to my scene.

I have a UI Root, with a Drop Panel Root. My sprites have box colliders, as does my target box. Here is my release code (which inherits from UIDragDropRelease)

  1. protected override void OnDragDropRelease (GameObject guy)
  2.         {      
  3.                 Debug.Log("Release Mine");
  4.                 if (guy!= null)
  5.                 {
  6.                         Debug.Log("Object is found");
  7.                 }
  8.                 base.OnDragDropRelease(guy);
  9.         }


If I take my sprites and copy paste them into the example scene 11, they work, the surface is detected when dragged over the box. If I take my box that Im trying to have things dropped onto, and place it in scene 11, it detects the surface.

I feel my scene is a mirror image of example 11.

So, given that:
a) I can successfull drag a UI element around the screen with UI drag item
b) Every time I release the object, even if over a box collider object, the surface is still always 0

What can you suggest I look at to figure out why the surface is never getting detected?


To Further Clarify:
1. If I bring in a drag object from my scene to the example scene, the surface is found when dragged over the box
2. If I bring my target box from my scene (where Im trying to drop items to) to the example scene, the example items will drop on to my sample box
3. If I bring the box and the draggable item from the example scene and add them to mine, the surface is not found

Ive noticed that the UICamera.hoveredObject is valid in the example scene buts its always null in mine.

Is there a reason that UICamera.hoveredObject could come up null when I am mousing over a box with a collider?
« Last Edit: August 04, 2014, 07:02:46 PM by Ace »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDragRelease Problem: Surface is NEVER detected
« Reply #1 on: August 05, 2014, 01:05:54 PM »
You forgot to attach the NGUI Event System (UICamera) to the Main Camera.

Ace

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 24
    • View Profile
Re: OnDragRelease Problem: Surface is NEVER detected
« Reply #2 on: August 05, 2014, 07:02:25 PM »
Thank you!

I watched the 6 tutorial videos (for the latest version) and that didn't come up.

What other documentation should I read to make sure I have a good bearing on how to implement and debug NGUI core features?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: OnDragRelease Problem: Surface is NEVER detected
« Reply #3 on: August 06, 2014, 09:28:45 PM »
I mentioned that in order to have objects receive events, one must attach UICamera to the camera that draws them (https://www.youtube.com/watch?v=jDxWG81sNPc&feature=youtu.be&t=1m17s), but I probably should have mentioned that you need to do this for every camera that you want to send out events. If ever you get confused as to what's getting events, use the "debug" checkbox on the UICamera. The rest... the documentation should cover it. If not, just ask on this forum.