UI Toolkit Scrolling Texture

I have been trying some stuff using UI Toolkit and I am a bit stuck on my implementation.

I am trying to develop a scrollable tiled background image with UI Builder, however, with the built-in does not offer offset’s for Texture2D, similar to Main Texture Offset for 2D Materials.

I am wondering if there is a way around this?

I think the closest you can do right now is to draw the texture using the UI Tookit Mesh API, for which you can provide you own custom UVs. Doing so would allow you to adjust the offset programmatically.

(sorry for the bad formatting in the above doc, we will fix that, let me know if you need help).

The provided code helps with rendering a static image, but how do you get the OnGenerateVisualContent method to get called again after you have added an offset to the uv values, to get a scrolling image?

EDIT: Sorry, I found MarkDirtyRepaint(), which seems to do the job.

1 Like