Author Topic: Trouble with TweenAlpha Duration Parameter  (Read 3617 times)

blitzer

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 52
    • View Profile
Trouble with TweenAlpha Duration Parameter
« on: January 26, 2015, 11:42:10 PM »
Hello everyone, I'm having an issue with using TweenAlpha.Begin(), where the Duration parameter does not seem to apply correctly.

What I'm doing in code:
  1. TweenAlpha.Begin(playerUIControlParent.gameObject, fadePlayerUIControls, 0f);

Description of Issue:
Pretty simple, I have a UI Widget that starts with a alpha of 1, and should fade to 0 over time. The problem is that this "transition" happens almost instantly (a few frames) even when the Duration is multiple seconds. I've tried changing the type of "Play Style" from "Once" to "Ping Pong" / "Loop" and everything seems fine as far as the duration is concerned, but as soon as I try it with "Once" again, it happens more/less instantly again.

Any ideas on what I'm doing wrong is appreciated, thank you for reading.

UPDATE:
It seems the issue was related to pausing the editor before the TweenAlpha script was finished running (in this case I was Breaking() one line after TweenAlpha.Begin() was called). As helped to be confirmed by r.pedra, Tween calculates time while the Editor is paused if Ignore timescale is checked. Once the Break() was removed, TweenAlpha's time duration worked correctly.
« Last Edit: January 28, 2015, 05:54:48 AM by blitzer »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #1 on: January 27, 2015, 04:40:29 AM »
Is that something that happens when you hit Play? Keep in mind that there is often a very long delay between the first frame after you hit Play() and the following ones.

blitzer

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 52
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #2 on: January 27, 2015, 11:16:33 PM »
Is that something that happens when you hit Play?
-No, unfortunately. In this case, when the last NPC/Player is "eliminated", the "game over sequence" starts which adds a TweenAlpha(Script) to the object in question (at which point the fade happens almost instantly).

I've also tried leaving the script on the object (stopping the sequence at that point), and have observed that changing the parameters to go back from 0 -> 1 and running the script also happens more/less instantly (but loop and ping pong seem about right).

UPDATE:
I believe I've figured out why this is happening, see original post for info if you are interested (and thank you for the help as always)...
« Last Edit: January 27, 2015, 11:37:39 PM by blitzer »

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #3 on: January 28, 2015, 05:23:56 AM »
I think if you uncheck "Ignore timescale" on the tween object, it won't "jump" to the end.

blitzer

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 52
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #4 on: January 28, 2015, 05:53:18 AM »
I think if you uncheck "Ignore timescale" on the tween object, it won't "jump" to the end.
-Yep, I just read the class docs and indeed, it states that having Ignore timescale checked will make it run through a game pause. Any idea why that is the default behavior? I'm sure there is a good reason for it, but off the top of my head I don't know why someone would want that behavior by default.

r.pedra

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 20
  • Posts: 131
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #5 on: January 28, 2015, 07:26:52 AM »
If you don't want it you can simply change it in UITweener.cs

blitzer

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 52
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #6 on: January 28, 2015, 11:53:37 PM »
True, I'm just afraid of causing some error by doing that, guess I'll give it a try and see what happens.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Trouble with TweenAlpha Duration Parameter
« Reply #7 on: January 29, 2015, 12:58:14 PM »
NGUI is a UI system, all its tweens should work even while the game is paused. That's why it ignores the timescale by default.