From 3de3ffa996b57c701c4cee23f58d063aade0e03e Mon Sep 17 00:00:00 2001 From: "Simon (darkside) Jackson" Date: Sat, 24 Oct 2020 11:36:40 +0100 Subject: [PATCH] Patch supplied by contributor to improve the texture sheet use with the UIParticlesystem --- Runtime/Scripts/Effects/UIParticleSystem.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Runtime/Scripts/Effects/UIParticleSystem.cs b/Runtime/Scripts/Effects/UIParticleSystem.cs index 6bd1897..2cf6b53 100644 --- a/Runtime/Scripts/Effects/UIParticleSystem.cs +++ b/Runtime/Scripts/Effects/UIParticleSystem.cs @@ -223,9 +223,10 @@ 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 (textureSheetAnimation.rowMode == ParticleSystemAnimationRowMode.Random) + { // FIXME - is this handled internally by rowIndex? + row = Mathf.Abs((int)particle.randomSeed % textureSheetAnimation.numTilesY); + } frame += row * textureSheetAnimation.numTilesX; break; @@ -234,7 +235,7 @@ namespace UnityEngine.UI.Extensions frame %= textureSheetAnimationFrames; particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x; - particleUV.y = 1.0f - Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y; + particleUV.y = 1.0f - ((frame / textureSheetAnimation.numTilesX) + 1) * textureSheetAnimationFrameSize.y; particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x; particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y; }