void Update ()
{
*****************************delta time
is the time period which I the application was paused, say 10
.0f sec
**************************************************** float delta = ignoreTimeScale ? RealTime.deltaTime : Time.deltaTime;
float time = ignoreTimeScale ? RealTime.time : Time.time;
if (!mStarted)
{
mStarted = true;
mStartTime = time + delay;
}
if (time < mStartTime) return;
*****************************calculated mFactor far too high, should be zero****************************************************
// Advance the sampling factor
mFactor += amountPerDelta * delta;
// Loop style simply resets the play factor after it exceeds 1.
if (style == Style.Loop)
{
if (mFactor > 1f)
{
mFactor -= Mathf.Floor(mFactor);
}
}
else if (style == Style.PingPong)
{
// Ping-pong style reverses the direction
if (mFactor > 1f)
{
mFactor = 1f - (mFactor - Mathf.Floor(mFactor));
mAmountPerDelta = -mAmountPerDelta;
}
else if (mFactor < 0f)
{
mFactor = -mFactor;
mFactor -= Mathf.Floor(mFactor);
mAmountPerDelta = -mAmountPerDelta;
}
}
// If the factor goes out of range and this is a one-time tweening operation, disable the script
*****************************calculated mFactor too high, should be zero****************************************************
if ((style == Style.Once) && (duration == 0f || mFactor > 1f || mFactor < 0f))
{
mFactor = Mathf.Clamp01(mFactor);
Sample(mFactor, true);
// Disable this script unless the function calls above changed something
if (duration == 0f || (mFactor == 1f && mAmountPerDelta > 0f || mFactor == 0f && mAmountPerDelta < 0f))
enabled = false;********************************* never had a chance to this tween in action *********************************
*********************************************** well atleast our OnFinish
delegate is called not breaking any game logic
********************************* if (current
== null) ***************** oh wait, current
is static and not
null (we can
't invoke other tweens from OnFinish?!)************************ {
current = this;
if (onFinished != null)
{
mTemp = onFinished;
onFinished = new List<EventDelegate>();
// Notify the listener delegates
EventDelegate.Execute(mTemp);
// Re-add the previous persistent delegates
for (int i = 0; i < mTemp.Count; ++i)
{
EventDelegate ed = mTemp[i];
if (ed != null && !ed.oneShot) EventDelegate.Add(onFinished, ed, ed.oneShot);
}
mTemp = null;
}
// Deprecated legacy functionality support
if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
current = null;
}
}
else Sample(mFactor, false);
}