From 23deee414a61012f54fa709d3f49199d0384517e Mon Sep 17 00:00:00 2001 From: Simon Jackson Date: Fri, 30 Jun 2017 17:29:36 +0100 Subject: [PATCH] Minor tweaks to UI Particle system following 5.5 update --- Scripts/Effects/UIParticleSystem.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Scripts/Effects/UIParticleSystem.cs b/Scripts/Effects/UIParticleSystem.cs index bf1d582..bb761f4 100644 --- a/Scripts/Effects/UIParticleSystem.cs +++ b/Scripts/Effects/UIParticleSystem.cs @@ -196,11 +196,11 @@ namespace UnityEngine.UI.Extensions { #if UNITY_5_5_OR_NEWER float frameProgress = 1 - (particle.remainingLifetime / particle.startLifetime); + frameProgress = _textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.remainingLifetime / particle.startLifetime)); // TODO - once Unity allows MinMaxCurve reading #else float frameProgress = 1 - (particle.lifetime / particle.startLifetime); -#endif - // float frameProgress = textureSheetAnimation.frameOverTime.curveMin.Evaluate(1 - (particle.lifetime / particle.startLifetime)); // TODO - once Unity allows MinMaxCurve reading frameProgress = Mathf.Repeat(frameProgress * _textureSheetAnimation.cycleCount, 1); +#endif int frame = 0; switch (_textureSheetAnimation.animation) @@ -214,9 +214,13 @@ namespace UnityEngine.UI.Extensions frame = Mathf.FloorToInt(frameProgress * _textureSheetAnimation.numTilesX); int row = _textureSheetAnimation.rowIndex; - // if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex? - // row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed); - // } +#if UNITY_5_5_OR_NEWER + if (_textureSheetAnimation.useRandomRow) + { + Random.InitState((int)particle.randomSeed); + row = Random.Range(0, _textureSheetAnimation.numTilesY); + } +#endif frame += row * _textureSheetAnimation.numTilesX; break;