Author Topic: UIButton  (Read 81295 times)

sintua

  • Jr. Member
  • **
  • Thank You
  • -Given: 7
  • -Receive: 0
  • Posts: 63
    • View Profile
Re: UIButton
« Reply #15 on: February 09, 2014, 09:31:55 PM »
Thanks for clarifying! I wasn't sure why the difference was there, helpful to know.

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: UIButton
« Reply #16 on: February 09, 2014, 10:17:38 PM »
Aren thanks, but how could i use OnPress on my component ? before i used :
  1.         void OnPress (bool pressed)
  2.         {
  3.                 if (enabled && pressedSprite != null)
  4.                 {
  5.                         pressedSprite.depth = (pressed)?11:7;
  6.                 }
  7.         }
  8.  

And how implements this now, with new EventDelegate ?
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #17 on: February 11, 2014, 09:02:06 PM »
You can still use the same OnPress function. Nothing has changed that. Event functions work as they did before. NGUI sends events, your scripts can receive them if they implement the appropriate functions, such as your "void OnPress (bool pressed)".

Now, if you wanted to have OnPress on some object trigger your own function elsewhere, consider looking at UIEventTrigger if you want it to be settable from inspector.

If not, UIEventListener.Get(targetGameObject).onPress += YourPressFunction; -- but this will expect your function to be "void YourPressFunction (GameObject go, bool pressed);"

zf223669

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
UIButton bug report
« Reply #18 on: March 04, 2014, 10:04:11 PM »
 in version 3.5.3,in UIButton Component,when I has chosen a sprite in Hover popup,now i want to delete it ,but it do not worK

nzen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: UIButton
« Reply #19 on: March 05, 2014, 04:53:32 PM »
After clicking a button with the mouse, how do we stop Joystick Button 0 from pressing it after?

Right now, I have to click the button, then click away from it to lose focus so the Xbox A button won't press it after.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #20 on: March 06, 2014, 12:15:43 PM »
@zf223669: Choose the same sprite as "Normal". I've added the delete button in 3.5.4, so you will see it when it goes live.

@nzen: Disable Controller Input on your UICamera.

SamK

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 13
    • View Profile
Re: UIButton
« Reply #21 on: April 04, 2014, 12:50:46 AM »
Hi ,
I can't find the UIEventTrigger script anywhere in the project. Neither in the interaction folder nor anywhere else.
I have NGUI 3.07 f3.
I need to perform some action on button press. OnPress
can you help in this regard ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #22 on: April 04, 2014, 10:47:40 PM »
You need to update NGUI. In the future always update before posting.

Nikul

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIButton
« Reply #23 on: April 06, 2014, 03:50:58 PM »
Hi, I'm using the UIEventTrigger on a button to initiate a bullet fire function via OnPress, then stop the function via OnRelease. The problem is if I drag my finger off the button(mobile), the UIButton script switches the button to normal, not pressed and the function continues to run because my finger is still down. Can we have an OnDragOut option in UIEventTrigger so we can end a button press if the finger is moved off the button but still pressed on the screen?
« Last Edit: April 06, 2014, 04:13:26 PM by Nikul »

yahodahan

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: UIButton
« Reply #24 on: April 06, 2014, 07:51:33 PM »
So, the click can still call a function, and (I don't precisely remember how this was done), pass the button object as a parameter, right? If I use the "UIEvent..." option, that is. Could I be reminded of how to get that object?

Any way to also pass through some value, which would be set (theoretically) on the button via inspector?

For example, a I have a big scrolly list of "map" thumbnails. I click on a map, that click needs to tell a "manager" script to swap the game to that map, base on what was clicked. I'd love to just pass an int, use it as an index in my maps array, etc.

Just being able to pass the Button Object itself will be workable, though :)

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #25 on: April 08, 2014, 01:22:14 AM »
@Nikul: Certainly. I'll add it to the next update.

@yahodahan: You can pass anything you like via event delegates as of 3.5.6.

Kevin Nguyen

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UIButton
« Reply #26 on: May 12, 2014, 08:57:46 PM »
Pro-Tip #2

UIButton comes with only an OnClick notification. If you want OnPress, OnHover, OnSelect, OnDoubleClick, and/or others -- attach UIEventTrigger script to your button (or any other object for that matter).

I can't find it! :(

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #27 on: May 13, 2014, 09:17:59 AM »
If you can't find the Event Trigger, then you are not on the latest NGUI version.

ababilinski

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 7
    • View Profile
Re: UIButton
« Reply #28 on: May 25, 2014, 12:39:30 PM »
To all who want to access the notify field in another script  :D! You gave to add an EventDelegate.
  1. EventDelegate Event = new EventDelegate();
  2. Event.set("The Code You Want To Set","The Function You Want To Call(As A String")
  3. UIButtonObject.GetComponent<UIButton>().onClick.Add(Event);
  4.  

Hope it helps people,
ababilinski :)

PoN

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 4
  • Posts: 111
    • View Profile
Re: UIButton
« Reply #29 on: May 29, 2014, 03:34:23 AM »
Example pls ? don't understand what is first param in Set method;
Worked on Doc&DogAge Of Fury 3D. Actually working on WarMach.