Author Topic: Moving buttons in game not based on mouse over.  (Read 1496 times)


  • Guest
Moving buttons in game not based on mouse over.
« on: July 17, 2013, 02:12:56 PM »
So, before i go and try and figure out how to do this with Playmaker, I thought i may as well ask this here first in case there was already a solution within NGUI (so as to avoid "reinventing the wheel.")

What i'm aiming for is a "weapon indicator" kinda thing... and I would like to have the buttons (well, progress bars so that i can factor in cool-down) move positionally based on a numeric value i can pass to it in some manner (the how to do that i'm thinking would be more a playmaker thing)

So, i'll give a little screenie to show what i mean. The first one is basically a quick move i did in the game to show that that weapon is active (i'm sure when i'm finished i'll add in some extra effects such as a glow, changing the font colour, etc. but i suspect that additional snazzy stuff i'll have to go deeper than what NGUI comes stock with.)

So, in the screenshot the second weapon would be active... in the first one none of them are active (their default state.)

Thing is, I would like to control it with a value instead of where the mouse is located... and it's positionally, not scaling.

Is this something that is available right out of the gate with NGUI as is or will i have to find a way to do that with coding/Playmaker?

Thank you for your time! p.s. glad i bought this... the trail is nice but the full version is much better (now that i'm getting re-familiarized with it.)

EDIT: Yes, I fully admit to being a total newbie... I don't mind the label, to be honest. and hey, we all had to learn at some point so may as well ask questions. :)
« Last Edit: July 17, 2013, 02:47:45 PM by Red »


  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Moving buttons in game not based on mouse over.
« Reply #1 on: July 17, 2013, 04:25:48 PM »
If these are all the stock UIButton instances, they each have the UIButtonOffset component attached to them. You can grab that component and then call the OnHover() method directly whenever the key is pressed. You will need to store a reference to those UIButtons somewhere, though, so you can specify the 2nd weapon.

  1. UIButtonOffset bOffset = myWeapons[2].gameObject.GetComponent<UIButtonOffset>();
  2. if (bOffset != null) {
  3.    bOffset.OnHover(true); // or false to de-selected it
  4. }


  • Guest
Re: Moving buttons in game not based on mouse over.
« Reply #2 on: July 17, 2013, 04:28:04 PM »
Okay! Thank you!

Though, since they're progress bars, would there be a problem (that you can imagine) if i drop on the appropriate script?