Skip to content
This repository was archived by the owner on Mar 20, 2023. It is now read-only.

Commit 0ab5e6e

Browse files
Merged in patch/uiparticlesystem-texture (pull request #104)
Patch supplied by contributor to improve the texture sheet use with the UIParticlesystem
2 parents b268970 + 3de3ffa commit 0ab5e6e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Runtime/Scripts/Effects/UIParticleSystem.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,10 @@ protected override void OnPopulateMesh(VertexHelper vh)
223223
frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
224224

225225
int row = textureSheetAnimation.rowIndex;
226-
// if (textureSheetAnimation.useRandomRow) { // FIXME - is this handled internally by rowIndex?
227-
// row = Random.Range(0, textureSheetAnimation.numTilesY, using: particle.randomSeed);
228-
// }
226+
if (textureSheetAnimation.rowMode == ParticleSystemAnimationRowMode.Random)
227+
{ // FIXME - is this handled internally by rowIndex?
228+
row = Mathf.Abs((int)particle.randomSeed % textureSheetAnimation.numTilesY);
229+
}
229230
frame += row * textureSheetAnimation.numTilesX;
230231
break;
231232

@@ -234,7 +235,7 @@ protected override void OnPopulateMesh(VertexHelper vh)
234235
frame %= textureSheetAnimationFrames;
235236

236237
particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
237-
particleUV.y = 1.0f - Mathf.FloorToInt(frame / textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.y;
238+
particleUV.y = 1.0f - ((frame / textureSheetAnimation.numTilesX) + 1) * textureSheetAnimationFrameSize.y;
238239
particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
239240
particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
240241
}

0 commit comments

Comments
 (0)