I want to animate a TextureRect in the context of animated UI, so that its texture changes every few milliseconds. I have done it with an editor, but I think it is prudent to do this aspect by code. I watched many tutorials and read the documentation, but I realised that most of the relevant tutorials are outdated because of the existence of AnimationLibrary.

I could not wrap my head around AnimationLibrary and I got stuck because of this issue. Is there a way to simply use an AnimationPlayer with an Animation resource instead of an AnimationLibrary?

Thank you in advance!

    You must be using 4.2. I hadn't seen that change before now either! There doesn't appear to be a way to use AnimationPlayer without an AnimationLibrary, although I'm sure you've seen for yourself that in-editor you can still have the same old workflow as it automatically creates a new library for you when you go to create a new animation.

    As for how to do it programmatically, I don't know. I suggest making sure you're reading the /latest/ docs.
    https://docs.godotengine.org/en/latest/classes/class_animationplayer.html
    https://docs.godotengine.org/en/latest/classes/class_animationmixer.html

    AnimationMixer is the new base class of AnimationPlayer. It looks like you can programmatically modify the AnimationLibrary(s) and the contained Animations through there.

    Yuzurukyun while you're researching, here's some additional methods:

    another option is to make sprites of the appropriate size, put them in a Control UI node then just using a state variable to determine which animations show when. Of course, that means proportioning the sprite correctly beforehand.

    If I'm not mistaken, you can load additional textures as Resources, preload them, and then just use some logic to determine what goes where.

    You could also achieve similar effects with the right shader, adjusting whatever shader_param you need to over time.