Add PropagateOpacity for controlling the alpha of entire UI node trees#15206
Add PropagateOpacity for controlling the alpha of entire UI node trees#15206UkoeHB wants to merge 4 commits intobevyengine:mainfrom
Conversation
|
Right now the modifiers are pre-multiplied when extracting, but we could also move the modifier into |
|
Not having looked at the code, I have a couple questions:
Raising these questions because I've wanted this before: #11157 (comment). UI-only and alpha-only is enough for UI fade in / out animations, though, which is already useful. |
Hmm yeah I don't see a technical limitation here. This PR is currently scoped to just-UI and just-alpha because that's as far as I've gotten while developing this idea. I'd like to focus on staying scope-constrained, and follow-up PRs can expand the functionality. |
Objective
Solution
PropagateControl,OpacityModifier, andBlockOpacityPropagationcomponents.PropagateControlwill accumulate modifiers down the UI hierarchy, and then those modifiers will be pre-multiplied to UI components when extracting to render them. You can also insertOpacityModifierdirectly as long as either there's no ancestor withPropagateControl, or you includeBlockOpacityPropagationon the entity. Also note thatOpacityModifierhas to be mutated every tick in order to be applied, which allows us to not care about hierarchy changes that might invalidate the modifier (and in another sense it enables manually setting the modifier since we never automatically remove it).Testing
transparency_uiexample to includePropagateOpacity.Showcase
TODO: this is showcase-worthy.