From 3aaed29acb146e32a3bf0980dec6d19ac50551db Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 5 Oct 2026 20:20:08 +0200 Subject: [PATCH] Add `Bypass` feature to `RenderToTextureControl` to skip rendering cached image (eg. for scripting) --- Source/Engine/UI/GUI/Common/RenderToTextureControl.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs b/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs index abaf69e21..24ce19cb4 100644 --- a/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs +++ b/Source/Engine/UI/GUI/Common/RenderToTextureControl.cs @@ -123,6 +123,12 @@ namespace FlaxEngine.GUI } } + /// + /// If checked, the control will be bypassed and will not render its children to texture, instead draw children normally. It can be used to temporarily disable the effect of this control without removing it from the hierarchy. + /// + [EditorOrder(200)] + public bool Bypass { get; set; } + #if FLAX_EDITOR private bool HasDrawMaterial => _drawMaterial != null; #endif @@ -152,6 +158,8 @@ namespace FlaxEngine.GUI } if (!_invalid) return; + if (Bypass && !_texture) + return; } _invalid = false; @@ -199,7 +207,7 @@ namespace FlaxEngine.GUI public override void Draw() { // Draw cached texture - if (_texture && !_invalid && !_isDuringTextureDraw) + if (_texture && !_invalid && !_isDuringTextureDraw && !Bypass) { var bounds = new Rectangle(Float2.Zero, Size);