Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - netpro2k

Pages: [1]
1
Support / Re: Playing tk2dAnimatedSprite when Time.timeScale = 0?
« on: June 22, 2013, 11:50:41 pm »
I think setting timescale to 0 when pausing the game is a fairly common technique. You often may want to have animated sprites as part of this paused UI which is where this comes into play.

I think it would probably be best to ad tk2dUISpriteAnimator rather than having this option show up on every sprite animator, as it is a somewhat special case. But I think it is a nice feature to have.

2
Support / Re: Playing tk2dAnimatedSprite when Time.timeScale = 0?
« on: June 22, 2013, 07:44:59 am »
Rather than duplicating the script, I just added a flag to tk2dSpriteAnimator like so:

tk2dSpriteAnimator.cs
Code: [Select]
/// <summary>
/// Interface option to make this animation ignore Time.timeScale
/// </summary>
public bool timescaleIndependant = false;

void LateUpdate()
{
UpdateAnimation(timescaleIndependant ? tk2dUITime.deltaTime : Time.deltaTime);
}


tk2dSpriteAnimatorEditor.cs
Code: [Select]
// Timescale Independant
bool newTimescaleIndependant = EditorGUILayout.Toggle("Timescale Independant", sprite.timescaleIndependant);
if (newTimescaleIndependant != sprite.timescaleIndependant) {
Undo.RegisterUndo(targetAnimators, "Sprite Anim Timescale Independant");
foreach (tk2dSpriteAnimator animator in targetAnimators) {
animator.timescaleIndependant = newTimescaleIndependant;
}
}

alternatively you might just subclass tk2dSpriteAnimator as say tk2dUISpriteAnimator

Pages: [1]