Author Topic: UIButton  (Read 98073 times)

hairyconiption

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: UIButton
« Reply #45 on: November 10, 2014, 03:05:44 PM »
I created an object to use as a prefab for all the items in my inventory. It works fine except the prefabs UIButton lose there target parameter when I create them. I am using
ItemObject = NGUITools.AddChild (ParentObject, ItemPrefab);
To create them, and I can modify all the values to be what they should be and place it fine in my scroll view.... What is going on? Why does the target get lost?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #46 on: November 10, 2014, 10:21:02 PM »
Prefabs can't reference anything outside the prefabs. Think about it, they don't exist as a part of your scene.

nagbharat92

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Question: UIButton
« Reply #47 on: April 13, 2015, 08:28:23 AM »
I've set onHover state to play a scale tween on a button. When i hit play on the unity game view, the buttons default (start state) is onHover. it comes scaled up already without me hovering over it. Any suggestions where i would have messed up? Sorry im fairly new to NGUI.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #48 on: April 16, 2015, 07:42:45 AM »
You need to disable the tween component. If you leave it enabled, it will start tweening as soon as you hit Play.

The-Arrival

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIButton
« Reply #49 on: January 27, 2016, 05:32:45 AM »
How do i only trigger the pressed state of a UIButton, when i click the left mousebutton?

by default a button and it´s remote method gets triggered by all onClick events which happens to be left, right and middle mousebutton clicks. I can easily make the remote trigger only on a left click using this:

  1. public void Button()
  2.     {
  3.         if (UICamera.currentTouchID == -1)
  4.         {
  5.             doStuff();
  6.         }
  7.        
  8.     }


But i have no idea how to trigger the UIButton components colorchange for "pressed" only for a specific pressed mousebutton, without changing the UIButton class itself.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #50 on: January 28, 2016, 11:06:47 PM »
This is already like that by default in the latest version of NGUI in the Pro repository (3.9.7). It's basically a matter of checking what the current touch ID. I modified the UIButton to do it, like so:
  1.         protected virtual void OnClick ()
  2.         {
  3.                 if (current == null && isEnabled && UICamera.currentTouchID != -2 && UICamera.currentTouchID != -3)
  4.                 {
  5.                         current = this;
  6.                         EventDelegate.Execute(onClick);
  7.                         current = null;
  8.                 }
  9.         }

The-Arrival

  • Newbie
  • *
  • Thank You
  • -Given: 5
  • -Receive: 0
  • Posts: 29
    • View Profile
Re: UIButton
« Reply #51 on: February 02, 2016, 05:31:10 AM »
Awesome. Thanks. I´ll wait until the changes are pushed to the Assets Store to update.

jezzurp

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: UIButton
« Reply #52 on: May 11, 2016, 05:11:01 AM »
Hi all, I'm new to this so appologies if I'm asking a stupid question...

When using a sprite with button component attached, and a label for the button nested as a child... is there an obvious way of making the label text hover in the same way that the sprite/ button BG has options for hover colour/active colour etc? I'm not sure if I'm being stupid and missing something obvious, or if it's something that's more difficult to do than I would expect?

Any help would be massively welcome, thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton
« Reply #53 on: May 14, 2016, 07:03:45 PM »
You can attach multiple UIButton / UIButtonColor components.