Skip to content

Commit

Permalink
added ability to toggle standard deltaTime and unscaledDeltaTime
Browse files Browse the repository at this point in the history
  • Loading branch information
prime31 committed Dec 26, 2014
1 parent 3832dcc commit 73c7072
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
16 changes: 15 additions & 1 deletion Assets/TransitionKit/TransitionKit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,20 @@ public class TransitionKit : MonoBehaviour
/// </summary>
public Material material;

/// <summary>
/// sets whether TransitionKit will use unscaledDeltaTime or standard deltaTime
/// </summary>
public bool useUnscaledDeltaTime = false;

/// <summary>
/// helper property for use by all TransitionKitDelegates so they use the proper deltaTime
/// </summary>
/// <value>The delta time.</value>
public float deltaTime
{
get { return useUnscaledDeltaTime ? Time.unscaledDeltaTime : Time.deltaTime; }
}


/// <summary>
/// holds the instance while we are transitioning
Expand Down Expand Up @@ -246,7 +260,7 @@ public IEnumerator tickProgressPropertyInMaterial( float duration, bool reverseD
var elapsed = 0f;
while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += deltaTime;
var step = Mathf.Lerp( start, end, Mathf.Pow( elapsed / duration, 2f ) );
material.SetFloat( "_Progress", step );

Expand Down
2 changes: 1 addition & 1 deletion Assets/TransitionKit/transitions/BlurTransition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public IEnumerator onScreenObscured( TransitionKit transitionKit )
var elapsed = 0f;
while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += transitionKit.deltaTime;
var step = Mathf.Pow( elapsed / duration, 2f );
var blurAmount = Mathf.Lerp( blurMin, blurMax, step );

Expand Down
12 changes: 6 additions & 6 deletions Assets/TransitionKit/transitions/PixelateTransition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public IEnumerator onScreenObscured( TransitionKit transitionKit )
var elapsed = 0f;
while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += transitionKit.deltaTime;
var step = Mathf.Pow( elapsed / duration, 2f );
transitionKit.material.SetFloat( "_CellSize", Mathf.Lerp( startValue, endValue, step ) );

Expand Down Expand Up @@ -90,22 +90,22 @@ public IEnumerator onScreenObscured( TransitionKit transitionKit )
break;
}

yield return transitionKit.StartCoroutine( animateScale( transitionKit.transform, duration * 0.5f, desiredScale ) );
yield return transitionKit.StartCoroutine( animateScale( transitionKit, duration * 0.5f, desiredScale ) );
}

#endregion


public IEnumerator animateScale( Transform transform, float duration, Vector3 desiredScale )
public IEnumerator animateScale( TransitionKit transitionKit, float duration, Vector3 desiredScale )
{
var originalScale = transform.localScale;
var originalScale = transitionKit.transform.localScale;

var elapsed = 0f;
while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += transitionKit.deltaTime;
var step = Mathf.Pow( elapsed / duration, 2f );
transform.localScale = Vector3.Lerp( originalScale, desiredScale, step );
transitionKit.transform.localScale = Vector3.Lerp( originalScale, desiredScale, step );

yield return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public IEnumerator onScreenObscured( TransitionKit transitionKit )

while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += transitionKit.deltaTime;
var step = Mathf.Pow( elapsed / duration, 2f );
var offset = Mathf.Lerp( 0, transitionDistance, step );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public IEnumerator onScreenObscured( TransitionKit transitionKit )

while( elapsed < duration )
{
elapsed += Time.deltaTime;
elapsed += transitionKit.deltaTime;
var step = Mathf.Pow( elapsed / duration, 2f );
var offset = Mathf.Lerp( 0, transitionDistance, step );

Expand Down

0 comments on commit 73c7072

Please sign in to comment.