unscaled delta time support

This commit is contained in:
2017-02-11 19:46:49 +07:00
parent 16ee7896bf
commit 290fd066b5
3 changed files with 79 additions and 13 deletions

View File

@@ -40,6 +40,9 @@ namespace FTRuntime {
[SerializeField]
bool _autoPlay = true;
[SerializeField]
bool _useUnscaledDt = false;
[SerializeField, SwfFloatRange(0.0f, float.MaxValue)]
float _rateScale = 1.0f;
@@ -95,6 +98,15 @@ namespace FTRuntime {
set { _autoPlay = value; }
}
/// <summary>
/// Gets or sets a value indicating whether controller uses unscaled delta time
/// </summary>
/// <value><c>true</c> if uses unscaled delta time; otherwise, <c>false</c></value>
public bool useUnscaledDt {
get { return _useUnscaledDt; }
set { _useUnscaledDt = value; }
}
/// <summary>
/// Gets or sets the controller rate scale
/// </summary>
@@ -296,9 +308,9 @@ namespace FTRuntime {
//
// ---------------------------------------------------------------------
internal void Internal_Update(float dt) {
internal void Internal_Update(float scaled_dt, float unscaled_dt) {
if ( isPlaying ) {
_tickTimer += dt;
_tickTimer += useUnscaledDt ? unscaled_dt : scaled_dt;
do {
var frame_rate = clip ? clip.frameRate * rateScale : 0.0f;
var frame_time = frame_rate > 0.0f ? 1.0f / frame_rate : 0.0f;