Author Topic: Tweens  (Read 71632 times)

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Tweens
« Reply #15 on: January 29, 2014, 01:24:40 PM »
Only the "event" that the tween has been enabled ( i had a class inheriting from uitweener which relied on this )

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweens
« Reply #16 on: January 29, 2014, 11:11:07 PM »
OnEnable is a generic Unity notification. Remove the "override" from your class, and you're good to go.

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: Tweens
« Reply #17 on: January 30, 2014, 11:39:23 AM »
Didn't know that. Thanks!  :D

OnlineCop

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 51
    • View Profile
Re: Tweens
« Reply #18 on: January 31, 2014, 01:47:18 AM »
(Correct any of this if it's wrong, but this is what I've come to understand...)

In order to make use of a tween's onFinished property, create a callback method and assign it via the EventDelegate.Add() method:

  1. void OnTween1Complete()
  2. {
  3.    // ...do stuff here...
  4. }
  5.  
  6. void MyButtonClicked()
  7. {
  8.    TweenScale tweenScale = TweenScale.Begin(gameObject, scaleAnimationTime, new Vector3(1.5f, 1.5f, 1.5f));
  9.    EventDelegate.Add(tweenScale.onFinished, OnTween1Complete);
  10. }
  11.  

Earlier implementations of UITweener allowed code such as:
  1.    TweenScale.Begin(gameObject, 1f, Vector3.one).onFinished += SomeMethod;
  2.  
but that has been deprecated in favor of the new format above.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweens
« Reply #19 on: January 31, 2014, 12:42:58 PM »
Yup that's correct. The EventDelegate approach works properly with inspector. System delegate does not.

zf223669

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Tweens
« Reply #20 on: March 05, 2014, 08:55:19 PM »
Now the tween Component can detect OnFinished state, If it could detect OnStart and OnUpdate state would be more Better!

balzaque

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: Tweens
« Reply #21 on: March 19, 2014, 02:04:27 PM »
Hi,

I'm trying to tween alpha property of a UISprite on a panel that have normals turned on so light can interact with it. When normals are selected the alpha property only sees to accept full values (0 or 1) but not anything in between (like 0.5f). Is this intended or maybe I'm doing something wrong?

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweens
« Reply #22 on: March 20, 2014, 02:28:29 AM »
I would say check the shader you're using. Maybe it doesn't use alpha as you'd expect? I see no reason why turning on normals would cause alpha tweens to not behave the same as before.

jlpeebles

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Re: Tweens
« Reply #23 on: November 28, 2014, 07:48:02 PM »
Ran into an issue trying to re-play a tween with code, I was trying to replay the tween with...
  1. tween.ResetToBeginning();
  2. tween.PlayForward();
This worked, but only if I set ignoreTimeScale off for some reason. Otherwise the tween would complete instantly.
From looking at UIPlayTween the following is correct. (And indeed works fine)
  1. tween.PlayForward();
  2. tween.ResetToBeginning();
Thought I'd point this out as it didn't seem obvious to me.

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: Tweens
« Reply #24 on: May 02, 2015, 10:19:49 AM »
Hi there,

I'm doing a simple app like interface using anchors, with a back button anchored to top left.
I assigned a position tween to anchored back button but it doesnt seem to work as expected.
What i want is that back button sticks to anchors, but when scene is loaded it comes from the left side (hidden area)

How can i achieve that?


Secondly can you please provide something like this officially?
https://unionassets.com/blog/empowerment-tween-animations-in-ngui-278

Thanks
« Last Edit: May 02, 2015, 11:50:59 AM by amraffay »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweens
« Reply #25 on: May 02, 2015, 10:13:51 PM »
Don't anchor the button. Anchor its parent. Since the button would be a child of an anchored object, you can animate it as you see fit.

amraffay

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 37
    • View Profile
Re: Tweens
« Reply #26 on: May 03, 2015, 02:53:17 AM »
Got it Thanks

dehinrsu

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
Re: Tweens
« Reply #27 on: October 03, 2015, 12:01:11 AM »
Hello,

At times the current state of the GameObject may not be the required initial state. Is it possible for you to add an overload Tween.Begin(GameObject, duration, From, To)?

As of now I am using Begin twice to keep the code clean and simple.

TweenAlpha.Begin(gameObject, 0, 0.25f);
TweenAlpha.Begin(gameObject, 0, 1);

Instead of the above, would like to have something like this.
TweenAlpha.Begin(gameObject, 0, 0.25f, 1);


Thanks
Vijay

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Tweens
« Reply #28 on: October 03, 2015, 06:49:37 PM »
Tween.Begin returns you an instance to the tween, so just change its from value.
  1. TweenAlpha tw = TweenAlpha.Begin(gameObject, 0f, 1f);
  2. tw.from = 0.25f;

Dune

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: Tweens
« Reply #29 on: October 23, 2016, 07:18:54 PM »
I noticed this code in TweenWidth. Did you know about the ?? operator? The ?? operator says, "if the value on the left is null, use the value on the right."

  1. public UIWidget cachedWidget { get { if (mWidget == null) mWidget = GetComponent<UIWidget>(); return mWidget; } }
  2. // replace with ...
  3. public UIWidget cachedWidget { get { return mWidget ?? (mWidget = GetComponent<UIWidget>()); } }
  4.