Author Topic: [RTS] Using NGUI and click into the 3d world  (Read 5065 times)

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
[RTS] Using NGUI and click into the 3d world
« on: July 27, 2013, 02:12:40 PM »
Hi there !
I'm working on a RTS game right now, and I have some issues using NGUI and some mouse controls into the game.
If I create a button into the UI camera, if I click on it, the code I made to click to the terrain in the 3d world will still be called.

How can I prevent this? I mean, I want to know if I click into the UI I won't raycast to my terrain.

Thanks !

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: [RTS] Using NGUI and click into the 3d world
« Reply #1 on: July 27, 2013, 02:18:39 PM »
Make a fullscreen collider under all your GUI, which handles a boolean that you have to look at to use your ingame click/dragging.

When the fullscreen collider is hit, allow dragging, when it's not it means a button was above it and took the touch, so don't allow dragging then.

Does that make sense?

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: [RTS] Using NGUI and click into the 3d world
« Reply #2 on: July 27, 2013, 02:23:23 PM »
I have to be sure that the NGUI callback will be called before the code to select into 3d world, but it could work.
I'll try !

Thanks.

cayou

  • Jr. Member
  • **
  • Thank You
  • -Given: 3
  • -Receive: 3
  • Posts: 90
    • View Profile
Re: [RTS] Using NGUI and click into the 3d world
« Reply #3 on: July 27, 2013, 02:44:42 PM »
Okay, it worked !
I have a function that allow the 3d clicking, it's called when the fullscreen collider is pressed.
And another one which block the 3d clicking into the same collider, on release event.

A bit tricky, but it works ;)