Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Pre-rendering part of an EditorWindow's GUI, storing as texture

Discussion in 'General Discussion' started by hedgehog90, Jan 14, 2018.

  1. hedgehog90

    hedgehog90

    Joined:
    May 18, 2016
    Posts:
    27
    Due to the complicated issue of clipping and manipulating GUI.matrix, I want to pre-render some elements of my GUI for the purposes of ease (some 90° rotated Labels within a ScrollView).
    Preferably, I'd like to render them before the first repaint of the GUI in question, and draw them as textures.
    Currently, I'm trying something similar to what's demonstrated here: http://angryant.com/2013/07/17/OnRenderTextureGUI/
    Simply switching RenderTexture.active to a new RenderTexture on the first repaint, and then back to the original.
    But the only way I've got this to work is by using the EditorWindow's layout + repaint OnGUI calls, which usually causes a brief flicker of the rendered image to be display in the EditorWindow.
    How can I render said GUI elements (or anything else for that matter) in a separate context, preferably synchronously? I have no need for layout gui calls either, if that helps.

    It might be a bit of an odd request considering the problem at hand, but I'm sure it'll come in useful further down the line, even if it isn't appropriate in this instance.