Color of ColorRect set in C# using Twine appear different in-game than when set using Godot's color picker

Godot Version

v4.3.dev6.mono.official [89850d553]

Question

When using Twine to programmatically transition between two colors on a ColorRect, the colors in-game end up appearing darker even though the exact same color hex value is being used in code as what appears in the color picker. Further, when printing the color to output, it shows the same values as the color picker still, even though visually they’re not.

Color picker values for title screen and settings screen respectively:


Code snippet for transitioning the color between title screen and settings screen respectively:

Tween tween = GetTree().CreateTween();

// Shift background color from title's color to settings' color
tween.Parallel().TweenProperty(GetNode("../../../%Background"), "modulate", new Color("#ca3a43"), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);

// Slide title HUD up off screen, slide settings HUD up from below screen
tween.Parallel().TweenProperty(GetNode("../../%SettingsHUD"), "offset", new Vector2(0.0f, -648.0f), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);
tween.Parallel().TweenProperty(GetNode("../../%TitleHUD"), "offset", new Vector2(0.0f, 0.0f), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);
Tween tween = GetTree().CreateTween();

// Shift background color from settings' color to title's color
tween.Parallel().TweenProperty(GetNode("../../../%Background"), "modulate", new Color("#6e70a4"), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);

// Slide settings HUD down off screen, slide title HUD down from above screen
tween.Parallel().TweenProperty(GetNode("../../%SettingsHUD"), "offset", new Vector2(0.0f, 648.0f), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);
tween.Parallel().TweenProperty(GetNode("../../%TitleHUD"), "offset", new Vector2(0.0f, 0.0f), 0.75f).SetTrans(Tween.TransitionType.Quint).SetEase(Tween.EaseType.Out);

Results in-game on title screen, then transitioning to settings screen, then back to title screen in that order:



Am I misunderstanding how color works in code versus in the color picker?

Any help would be appreciated. Thanks! :grin:

obraz

2 Likes

Thank you very much and sorry for the late response!

I was following some online tutorials that used modulate, my bad. This solved my issue! :grin:

1 Like