UI-Transparency Module Script for fading/setting the transparency of any ui object and all of its descendants


I’ve started working on a bunch of the UI for my game and found that I have several UIs that I wanted to fade in and out instead of just using the Visible property to instantly display or hide them. It’s kind of a nuisance to have to do this when the UIs will have a large amount of descendants, so I made a module script that will work with any UI’s transparency and all of its descendants’ transparencies.

It comes with two methods, set and fade.

‘Set’ simply sets the transparency of a UI object and all of its descendants.

‘Fade’ allows you to smoothly fade the transparency of a UI object and all of its descendants from one value to another (with additional parameters for the duration of the fade and how frequently per second the transparency will update).

Additional notes:

  • It takes consideration of the original transparency of each individual object. For example, if a frame in your UI has a transparency of 0.5 (50% opaque) and you set the UI’s transparency to 0.5, the frame will now have a resulting transparency of 0.75 (25% opaque).

  • It stores the original transparency values of the entire UI hierarchy at the moment you first call ‘set’ or ‘fade’ on that UI. Successive method calls on the same UI will retrieve those stored values of the original transparencies of every object in that UI hierarchy.

  • It changes all types of UI transparency: BackgroundTransparency, ImageTransparency, TextTransparency and TextStrokeTransparency.

I figured I might as well share this. It makes it quick and simple to accomplish a task that’s otherwise a bit more tedious and annoying to do, especially with very large UI hierarchies.

Here you go!


Fantastic module!

However, I would put this in #learning-resources:community-tutorials-resources since this is a resource the community can use. :slight_smile: