Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: ENAY on July 13, 2012, 02:54:13 AM

Title: UICamera.selectedObject one frame behind
Post by: ENAY 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?
Title: Re: UICamera.selectedObject one frame behind
Post by: joreldraw on July 13, 2012, 03:22:26 AM
Use UICamera.lastHit
Title: Re: UICamera.selectedObject one frame behind
Post by: ENAY on July 13, 2012, 05:08:01 AM
I tried that before I posted and all I got was RayCast Hit all the time.
Title: Re: UICamera.selectedObject one frame behind
Post by: joreldraw on July 13, 2012, 05:24:40 AM
You need to filter how you like

i.e.: Uicamera.lastHit.transform.name
Title: Re: UICamera.selectedObject one frame behind
Post by: ENAY on July 14, 2012, 11:24:44 PM
joreldraw!

You sir, are the man!  8)

Thanks for that.
Title: Re: UICamera.selectedObject one frame behind
Post by: wizardsmoke 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