Author Topic: UICamera.selectedObject one frame behind  (Read 3681 times)

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
UICamera.selectedObject one frame behind
« on: July 13, 2012, 02:54:13 AM »
Ok, I am using UICamera.selectedObject. After a button click I Debug.Log to see what is in the message and annoyingly it is always the previous message. So if I click on Button6 and then Button2, it will return Button6 instead of Button2.
Maybe I have my update in the wrong place. I am checking for button presses using onPress, does that mean I can't get the selectedObject until I release the button? (I want to have the result as soon as I press the button)

Any ideas?

joreldraw

  • Guest
Re: UICamera.selectedObject one frame behind
« Reply #1 on: July 13, 2012, 03:22:26 AM »
Use UICamera.lastHit

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UICamera.selectedObject one frame behind
« Reply #2 on: July 13, 2012, 05:08:01 AM »
I tried that before I posted and all I got was RayCast Hit all the time.

joreldraw

  • Guest
Re: UICamera.selectedObject one frame behind
« Reply #3 on: July 13, 2012, 05:24:40 AM »
You need to filter how you like

i.e.: Uicamera.lastHit.transform.name

ENAY

  • Full Member
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 248
    • View Profile
Re: UICamera.selectedObject one frame behind
« Reply #4 on: July 14, 2012, 11:24:44 PM »
joreldraw!

You sir, are the man!  8)

Thanks for that.

wizardsmoke

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 5
  • Posts: 40
    • View Profile
Re: UICamera.selectedObject one frame behind
« Reply #5 on: January 30, 2014, 05:57:30 PM »
Thanks, this is a great way around the weirdness of UICamera.selectedObject.  UICamera.hoveredObject seems a bit easier to use, though.  :D