Search Unity

[UI] (RenderTexture + Material) Breaks on SetQualityLevel

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by McMayhem, Mar 12, 2016.

  1. McMayhem

    McMayhem

    Joined:
    Aug 24, 2011
    Posts:
    443
    Hello all.

    So I’ve had this issue actually since 5.2. It wasn’t as big a deal then because the issue only happened in the editor and not in the build. Now it’s happening in the build too so I figured I would share and see if this is really a bug or if it’s just something I’m doing wrong.


    What I’m Doing: I’m rendering my game’s HUD using a separate camera. The normal camera layering technique as seen here is no good for me as I’m using Deferred Shading as well as image effects on the UI camera. I also can't use the standard Screen Space Camera canvas because I'm using AmplifyMotion which distorts the UI when it's set to that.

    So my only alternative was to render the UI to a RenderTexture and then use that in a RawImage on my Overlay Canvas that renders the normal, non-bloomed UI. The effect creates something like this:



    Problem: Everything works beautifully under normal conditions. You can start, load, save, quit and the HUD doesn’t freak out. The only issue is when you change any of the settings that requires expensive SetQualityLevel calls. When applying changes, the settings code calls the necessary SetQualityLevel() for whatever options were set. Once this happens, there is a divergence in behavior from the EDITOR and the BUILD.

    EDITOR: I lose the HUD and only have the Overlay UI visible.

    BUILD: Screen turns white and the game must be exited manually.


    After researching for quite a while, I’ve discovered this is an issue with the MATERIAL attached to the RawImage that is using the RenderTexture.

    I’ve found that if I delete the material, the RenderTexture image shows up just fine. Of course, I need the material in order to get rid of the black background so you can see stuff behind the HUD.

    TLDR: Calling SetQualityLevel() for things such as AA and Shadows globally breaks RenderTextures when used with a material of any kind. Not sure if this is a bug, or if there is something I need to do after applying graphics settings to get it to work again.


    Things I’ve tried:
    - Resetting the material. Adding a new material. Swapping materials. (no matter what I do to the material property of the RawImage component, it still won’t show anything with the material property set to anything other than “none”.)
    - Destroying the RenderTexture and creating a new one.
    - Setting the RawImage as dirty
    - Programmatically removing the RawImage and replacing it with a new component.
    - Using Graphics.DrawTexture to draw the image instead of the UI. This loses its information when using SetQualityLevel() as well. No material used.
    - Searching for similar, solved issues.
     
  2. Griz

    Griz

    Joined:
    Aug 27, 2013
    Posts:
    108
    Necroing because of the same problem happening here in the version 2018.2.1f1.

    Our project uses multi camera setup, render textures for post processing and deffered shading.
    Both IGUI and UGUI break in build after changing the quality level through SetQualityLevel().