Author Topic: [bug] OnPress( false ) is not called when...  (Read 13135 times)

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
[bug] OnPress( false ) is not called when...
« on: December 18, 2015, 04:53:54 AM »
OnPress( false ) is not called when the pressed object is tween out by parent + inactive when release.

how to test
1. Create ui like this
UIRoot
  |-UICamera
        |-GameObject
              |-Button

2. attach KeyBinding to GameObject, use escape key to click
3. attach PlayTween to GameObject, disable after forward
4. attach TweenPosition to GameObject
5. press on the button, don't release it
6. press escape key
7. release mouse, and no Press( false ) called.

that won't happen if the tween position is on Button.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #1 on: December 18, 2015, 01:37:31 PM »
That's always been like that. NGUI sends events via SendMessage, and SendMessage doesn't work on inactive game objects.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #2 on: December 18, 2015, 01:50:34 PM »
if i tween the button itself, it send press( false ) right away when the tween start.
but if the tween is on the parent( GameObject in the example ), it don't.

i report the issue because it works different.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #3 on: December 22, 2015, 01:59:36 AM »
hi ArenMook, is that an issue? about the parent's/self's tween v.s. press(false)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #4 on: December 23, 2015, 09:26:06 AM »
I'll pencil it in as "just how it works", but you can try changing UIButtonColor's OnDisable like so:
  1.         protected virtual void OnDisable ()
  2.         {
  3. #if UNITY_EDITOR
  4.                 if (!Application.isPlaying) return;
  5. #endif
  6.                 if (mInitDone && mState != State.Normal)
  7.                 {
  8.                         SetState(State.Normal, true);
  9.  
  10.                         if (tweenTarget != null)
  11.                         {
  12.                                 TweenColor tc = tweenTarget.GetComponent<TweenColor>();
  13.  
  14.                                 if (tc != null)
  15.                                 {
  16.                                         tc.value = mDefaultColor;
  17.                                         tc.enabled = false;
  18.                                 }
  19.                         }
  20.                 }
  21.         }

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #5 on: December 24, 2015, 11:57:40 AM »
thanks, i will treat the script code as a temporary solution.

gyd

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 87
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #6 on: December 25, 2015, 02:44:03 AM »
tried the code.
the press( false ) still dont be called.

txlml

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: [bug] OnPress( false ) is not called when...
« Reply #7 on: December 30, 2015, 04:23:52 AM »
try my code! 8)
« Last Edit: August 16, 2016, 02:00:07 AM by txlml »