Author Topic: UIButton.onClick non-invocable?  (Read 4142 times)

johanesnw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 22
    • View Profile
UIButton.onClick non-invocable?
« on: August 12, 2014, 11:19:39 AM »
I have a Panel with Animation.
and a button with UIPlayAnimation.

lets just say it's a close_btn that plays the reverse animation of Panel, then disable it on reverse, and Do a script OnFinished.
but I want to play the reverse animation too if I click something that's not an UIButton. its not even an UI element.

I try to access the close_btn.onClick() to play the Panel animation (including the disable on reverse and Do script OnFinished)
but it's non-invocable. then how do I trigger that UIPlayAnimation?
Playing it's animation is still do-able with ActiveAnimation.Play(anim,direction); but what I really need is that
OnFinished.

tried to add Active Animation script on the Panel, then assign some script to disable it
but the OnFinished events seems doesn't work.

TypoStraw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: UIButton.onClick non-invocable?
« Reply #1 on: August 12, 2014, 12:04:13 PM »
You can invoke the onClick this way: EventDelegate.Execute(close_btn.onClick);

However, if I understand your problem correctly, it would probably be better to just keep a reference of the UIPlayAnimation component and then activate the Play method through that variable when needed.

johanesnw

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: UIButton.onClick non-invocable?
« Reply #2 on: August 12, 2014, 12:26:17 PM »
I've tried keeping UIPlayAnimation. actually it can work with some extra scripting,
but I want to enable another Panel after this Panel's reverse animation finished so it looks like the Panel is flipping (like LINE cookie run's friendlist panel)

it works well if I click the close_btn, but when I try to do the extra scipting, I can't acces the OnFinished so the 2nd Panel is enabled before 1st Panel animation finished (both Panels will present for about 0.3sec). so the Flipping Panel trick looks really poor.
unfortunately your code is not working.  :-[

EDIT:
For now I just disable the Panel than to use animation reverse. It looks like this. actually there's no close_btn so I use the START_btn to demonstrate the Result that I want.
Main UI Demo

just a demo . assets are taken from assetstore.
« Last Edit: August 12, 2014, 01:23:58 PM by johanesnw »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIButton.onClick non-invocable?
« Reply #3 on: August 13, 2014, 07:36:37 AM »
If you want to show one panel after another fades out, I strongly advise you to make a windowing system like I did for Starlink UI Kit. It's a trivial yet very useful system (I most recently re-used it in Windward just a few days ago). You open windows by calling UIWindow.Show(panel). Doing it again on another window will hide the first, and show the 2nd. Better yet, you can then call UIWindow.GoBack() and it will close the current window and open the previous. It keeps history like that. There is also UIWindow.Close(), and UIWindow.Hide(panel).