Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: scheissmann on May 27, 2013, 06:35:17 PM

Title: Button position resetting when mouse hovers over it
Post by: scheissmann on May 27, 2013, 06:35:17 PM
Hi all,

I'm trying to create a "dynamic" menu, the menu is a background sprite with a few prefabbed (created in editor) buttons. The buttons are originally located somewhere far away in the scene that cannot be seen. When the menu is called, the code will move the background and buttons to a specific position on a screen so they can be clicked. The buttons get moved and all but I realized that as soon as I hover my mouse over the buttons, the button will go back to its original position, as though the "OnHover" function of the button moves the button back to its original location. Is there a way to stop it from moving back?

Thank you very much :)

Title: Re: Button position resetting when mouse hovers over it
Post by: scheissmann on May 27, 2013, 06:44:15 PM
I think it's a bug with UIButtonOffset, because if I disable this component then the button works fine.
and it looks like in the UIButtonOffset code, the tweenTarget is set to "transform" in Start() function, so once the button is moved, the tweenTarget is not updated so the button goes back to where it originally located when hovered. I think when OnHover is called in UIButtonOffset, if tweenTarget is updated again then the button should work fine.

Could you please look into this?

Thanks!
Title: Re: Button position resetting when mouse hovers over it
Post by: ArenMook on May 28, 2013, 02:15:30 AM
You should limit to one tween per object. If a button has a tween on it, this tween will remember its starting position.

Consider moving in the button's parent rather than the button itself.
Title: Re: Button position resetting when mouse hovers over it
Post by: scheissmann on May 28, 2013, 10:50:12 AM
Hi Aren, thank you for the clarification, I agree that if you move the parent then the button will have no issue.

I'm wondering, shoudln't the tweentarget variable be a gameobject rather than a transform? If it's a gameobject then if the tweentarget happens to move at run time, it's location will be updated.