Forum rules - please read before posting.

UI animation playback speed

Unity 6.3
AC 1.75.8 (I know! :# )
Hello, I'm running into some trouble with the speed of UI animations. I have a menu with Aventure Creator as it's source and an animated Graphic element. It's a sprite sheet with the Animate? toggle checked and animation speed set to 1. The problem is that it runs at widly different speeds in editor vs build. I have also had a similar issue with an animated Interaction Icon that was being used to flash hotspots. On my machine it ran at the same speed in editor vs build, but I noticed it running super fast for a couple of other people. I'm wondering if these sprite sheet animations are somehow framerate dependant? And if so is there a way to get them to hit a consistent speed?
Thanks!

Comments

  • I'll need to look into it more deeply, I think you may well be right! Thanks for raising this issue, I'll do some digging.

  • edited June 16

    OK. If you open up AC's CursorIcon script, look for the GetAnimatedRect function without any parameters - around line 673.

    Replace it with:

    private float lastAnimationSetTime;
    public Rect GetAnimatedRect ()
    {
        if (frameWidth < 0f)
        {
            Reset ();
        }
    
        if (frameIndex < 0f)
        {
            frameIndex = 0f;
        }
        else if (frameIndex < numFrames)
        {
            if (endAnimOnLastFrame && frameIndex >= (numFrames -1))
            {}
            else
            {
                int i = Mathf.FloorToInt (frameIndex);
                float frameSpeed = (frameSpeeds != null && i < frameSpeeds.Length) ? frameSpeeds[i] : 1f;
    
                var deltaTime = Time.unscaledDeltaTime - lastAnimationSetTime;
                frameIndex += deltaTime * animSpeed * frameSpeed;
            }
        }
    
        lastAnimationSetTime = Time.unscaledTime;
    
        int currentRow = 1;
        int frameInRow = Mathf.FloorToInt (frameIndex)+1;
        while (frameInRow > numCols)
        {
            frameInRow -= numCols;
            currentRow ++;
        }
    
        if (frameIndex >= numFrames)
        {
            if (endAnimOnLastFrame)
            {
                frameIndex = numFrames - 1;
                frameInRow -= 1;
            }
            else
            {
                if (skipFirstFrameWhenLooping && numFrames > 1f)
                {
                    frameIndex = 1f;
                    frameInRow = 2;
                }
                else
                {
                    frameIndex = 0f;
                    frameInRow = 1;
                }
    
                currentRow = 1;
            }
        }
    
        if (texture)
        {
            uniqueIdentifier = texture.name + frameInRow.ToString () + currentRow.ToString ();
        }
    
        return new Rect (frameWidth * (frameInRow-1), frameHeight * (numRows - currentRow), frameWidth, frameHeight);
    }
    

    Does that resolve it?

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.