Repository navigation
KodeKit: colour tints without uGUI's tween garbage - #2779
Merged
Merged
Conversation
uGUI's ColorTint transition runs Graphic.CrossFadeColor on every state change, which builds a tween callback and starts a coroutine: about 1 KB of garbage per pointer event (enter, down, up, exit) on every colour-tinted control. Most KodeKit controls are: segmented cells, stepper buttons, role buttons, list rows, title-bar icons, toggles and switches, and buttons in skins without hover sprites. InstantTint sets the Selectable's transition to None and paints the same ColorBlock colours into the target graphic's canvas renderer at once, following Unity's state order (disabled, pressed, selected, highlighted, normal). A change of interactable, by code or a CanvasGroup, is caught by one shared per-frame check over the live tints (a field read each). The 50 ms colour fade of segmented and painted controls is gone: the colour changes at once. Sprite-swap skins hand the Selectable back to its own transition.
A restyle switches a widget's look back and forth in one frame: the skin's sprite-swap button look, then the widget's own colour tint. Destroy is deferred to the frame's end, so Use found the dying component and the control was left with no transition and no hover.
Contributor
✅ Build Artifact 🚀MechJeb2-aaea957.zip (built from 7dac3f0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
uGUI's
ColorTinttransition runsGraphic.CrossFadeColoron every state change of a Selectable. That builds a tween callback and starts a coroutine each time: about 1 KB of garbage per pointer event (enter, down, up, exit). Most KodeKit controls use it: segmented cells, stepper buttons, role buttons, list rows, title-bar icons, switches and checkboxes, and buttons in skins without hover sprites. A person moving the mouse makes a few such events a second, so it's a few KB a second, but it is the one place KodeKit still allocates per interaction.KodeKit.InstantTintsets the Selectable's transition to None and paints the sameColorBlockcolours into the target graphic's canvas renderer at once, as the transition does at the end of its fade:interactable(code, or a CanvasGroup) is caught by one shared per-frame check over the live tints (a field read each);Visible change: the 50 ms colour fade on segmented and painted controls is gone; the colour changes at once.
Measured in KSP (MJTesting pad, release player,
-c Release, 10 windows of 15 widgets each, every button and toggle hovered, pressed, released and left every frame; Spike 131 in MechJeb2_UI, jobs J21 on this branch and J22 on dev in the same session):The hover still shows: a hovered segment's canvas colour goes from alpha 0 to 0.10 at once (dev: 0.005 a frame later, mid-fade);
kodekit_flat_hovered.jpgshows a hovered segment and a pressed stepper button.Not changed: KodeUI's own defaults (
UIScrollbar,UISliderkeep uGUI's ColorTint; KodeUI is changed upstream), and a checkbox's tick still fades in with uGUI'sCrossFadeAlphawhen it toggles (a click, not a hover).