UI Particles: Texture sheet animation + Random row

Issue #256 resolved
Vladyslav Lukianenko created an issue

Hello! Currently, when using UIParticleSystem.cs, having a random row animation is unsupported. It always results in playing the last row. Expected behavior: each particle selects random row from texture sheet animation to play.

Comments (8)

  1. Simon Jackson

    That's probably a limitation of the current implementation @vlukianenko I'm afraid.

    If you can help and see what would need to be done to include other texture sheet rows, that would be great.

  2. 이진수

    switch (textureSheetAnimation.animation)                    
    {                           
        case ParticleSystemAnimationType.WholeSheet:
            frame = Mathf.FloorToInt(frameProgress * textureSheetAnimationFrames);
            break;
    
        case ParticleSystemAnimationType.SingleRow:
            frame = Mathf.FloorToInt(frameProgress * textureSheetAnimation.numTilesX);
    
            int row = textureSheetAnimation.rowIndex;
            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;
    }
    
    frame %= textureSheetAnimationFrames;
    
    particleUV.x = (frame % textureSheetAnimation.numTilesX) * textureSheetAnimationFrameSize.x;
    particleUV.y = 1.0f - ((frame / textureSheetAnimation.numTilesX) + 1) * textureSheetAnimationFrameSize.y;
    particleUV.z = particleUV.x + textureSheetAnimationFrameSize.x;
    particleUV.w = particleUV.y + textureSheetAnimationFrameSize.y;
    

  3. 이진수

    Sorry my answer was late. Unfortunately, the demo you requested cannot be produced. However, as a result of my testing, I found that the texture at the last index is represented.

  4. Simon Jackson

    I’ve tested the updated script with the existing UI Particle scene configured as a Textture Animation and it seemed to work as expected, so the code was merged.
    Thanks for the contribution!

  5. Log in to comment