Author Topic: [Resolved] Re-activate OnSelect Event  (Read 1853 times)

birlouz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
[Resolved] Re-activate OnSelect Event
« on: February 24, 2014, 07:18:39 PM »
Hello,

I've some gameObjects with UIEventListeners added on it.
I linked the OnPress and OnSelect events, when I click on a gameObject, the OnPress and the OnSelect events are called (I can see that with Debug output).
The problem is when I click again on the same gameObject, the OnPress event is called, but not the OnSelect whereas when I click on another gameObject, the both events are called.

Is there a way to "re-activate" the OnSelect event on an already clicked gameObject ?

Thanx in advance,
Birlouz.

« Last Edit: February 27, 2014, 12:21:24 PM by birlouz »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Re-activate OnSelect Event
« Reply #1 on: February 25, 2014, 02:36:41 PM »
OnSelect is called on an object that you pressed on the first time. Repeated press events on the same object won't result in another OnSelect. That's the point of the event -- to convey selection.

birlouz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Re-activate OnSelect Event
« Reply #2 on: February 26, 2014, 12:38:28 PM »
I understand :), thank you for the answer, but is there a way to manually, through c# script, set selection to "false" on the selected object so it can receive another OnSelect event ?
Here is what I want to achieve, I've a fullscreen grid of gameObject with a UIEventListener on each.
When I click on one object, some UIButtons appears to let you choose an action.
I wanted to make disappear those buttons when the user click anywhere but on the buttons.
But if the user doesn't click on the button but anywhere on the screen, he clicks on a gameObject of the grid sending an unwanted OnSelect event to this object ... and I would like to reset the selection state of this gameObject so it can be selected again.
I'm not english and it's difficult to be really precise on my explanation :( ...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Re-activate OnSelect Event
« Reply #3 on: February 26, 2014, 02:34:20 PM »
UICamera.selectedObject = null;

birlouz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: Re-activate OnSelect Event
« Reply #4 on: February 27, 2014, 10:15:16 AM »
Works perfectly !! Thank you !!  :)