Hey there,
is there the possibility to update a RenderTexture that is set as an Background Image for a VisualElement every frame?
I have set a Rendertexture that gets updated every frame as a Background image for a visual element in a custom editor.Currently the Render Texture displayed is updated only every other frame, which seems to be more frequent when i hover over the inspector or click into other fields inside of the editor. I display the same RenderTexture on a Canves inside the scene, so i know that it is properly updating.
Is there a way to force an update of a Visual element inside of the custom Editor? Or should i use another method to display a RenderTexture inside a custom Editor?
Editor Windows are only redrawn if necessary (i.e. if anything changes). That’s why you see it update more often if you hover or if you drag a slider in it etc.
You can force a redraw:
If you have another process feeding the render texture then maybe this could also issue a redraw when needed.
Thanks for the suggestion of repainting the editor, but i would be more interested in only redraw the visual element with the render texture. One of the benefits of the new ui system is that only necessary parts need to be redrawn and i was hoping to restrict the redraw to this.
Hello! You can call MarkDirtyRepaint on the visual element you need to update: Unity - Scripting API: UIElements.VisualElement.MarkDirtyRepaint. I believe this will ultimately repaint the whole window in this case, but there’s no other options at the moment.