Author Topic: Tweening problems  (Read 1424 times)

Tomleung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Tweening problems
« on: May 18, 2014, 02:47:25 AM »
I have a situation here:

I have a gameobject that has two tween alpha scripts attached. One will start automatically at start and the another will run after finishing the first tween alpha script. In order to do this, I want to set when the first tween alpha script finished and the another tween alpha script runs and so I do it at OnFinished. However, when I want to select the method, I just can find one tween alpha script and select the relative actions. So it won't works. It seems that it can not identify multiple but same tween script all attached in one gameobject. How can I do?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweening problems
« Reply #1 on: May 18, 2014, 11:38:25 AM »
It's not easy to do this via inspector. Why have two alpha tweens on the same object? If you want to fade something in then fade something out, then play the same exact tween, just in reverse. Alternatively use PlayTween to trigger them and give them each a unique group ID.

Tomleung

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: Tweening problems
« Reply #2 on: May 27, 2014, 05:06:57 AM »
So if I want a UItexture first
tweenalpha from 0 to 1 with 5 seconds duration

and then immediately
tweenalpha from 1 to 0 with 2 seconds duration.

How to implement it?
And it is automatically run and so UIplayTween seems not useful for this case.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweening problems
« Reply #3 on: May 28, 2014, 06:52:32 AM »
  1. public void PlayMyTween ()
  2. {
  3.     TweenAlpha ta = TweenAlpha.Begin(gameObject, 5f, 1f);
  4.     ta.alpha = 0f;
  5.     EventDelegate.Add(ta.onFinished, ContinueMyTween);
  6. }
  7.  
  8. public void ContinueMyTween ()
  9. {
  10.     TweenAlpha.Begin(gameObject, 2f, 0f);
  11. }
No need to attach any tweens beforehand.