Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

releasing render texture that is set as Camera.targetTexture!

Discussion in 'Scripting' started by BisuDagger, May 9, 2016.

  1. BisuDagger

    BisuDagger

    Joined:
    May 2, 2014
    Posts:
    31
    Hello all,
    releasing render texture that is set as Camera.targetTexture is a problem that has popped up for many people with no solution. When you create a render texture in code, for example:
    Code (csharp):
    1.  
    2.   // Create a render texture
    3.   panelTexture = new RenderTexture((int)imageSize.x, (int)imageSize.y, 24, RenderTextureFormat.ARGB32);
    4.   panelTexture.antiAliasing = 2;
    5.   panelTexture.Create();
    6.   panelImage.GetComponent<RawImage>().texture = panelTexture;
    7.  
    8.   panelInfo.panelCamera.targetTexture = panelTexture;
    9.  
    If you press "Alt +Enter" to toggle fullscreen or not, then the "releasing render texture that is set as Camera.targetTexture" error will pop up (I'm using SRDebugger to determine this). The result is the render texture turning completely white and all objects involved with that object like my panelCamera.targetTexture no longer have a reference to it.

    Can anyone out there suggest a way to keep the render texture during full screen toggle?
     
  2. BisuDagger

    BisuDagger

    Joined:
    May 2, 2014
    Posts:
    31
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,095
    I'm not aware of this issue. Have you filed a bug report?
     
  4. BisuDagger

    BisuDagger

    Joined:
    May 2, 2014
    Posts:
    31
  5. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    2,667
    Yes, this has been a bug for a very long time.
     
  6. BisuDagger

    BisuDagger

    Joined:
    May 2, 2014
    Posts:
    31
    That is correct. They fixed it on I believe 5.4. Thanks for the reply.
     
  7. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    2,667
    I experienced it in 5.5 yesterday
     
  8. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,095
    Did anyone file a bug report?
     
  9. infinitypbr

    infinitypbr

    Joined:
    Nov 28, 2012
    Posts:
    2,667
    I can't reproduce it. It's random. It happened twice, when I Saved the scene. But it doesn't happen all the time. There doesn't seem to be any rhyme or reason.
     
  10. Jodon

    Jodon

    Joined:
    Sep 12, 2010
    Posts:
    395
    I'm getting this error when saving my scene. All of the Cameras lose their references to the RenderTexture upon saving. The project's quite big so I don't think I'll be able to file a report, seems random.
     
    infinitypbr likes this.
  11. ZDestructor

    ZDestructor

    Joined:
    Nov 8, 2012
    Posts:
    118
    Getting this in 5.6.0f3
    I have a script(ExecuteInEditMode) that creates RenderTexture's and assigns them to cameras on the same GameObject.
    They seem to get released(inconsistently) when I play/stop.
     
  12. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,095
    Can you file a bug report please?
     
  13. ZDestructor

    ZDestructor

    Joined:
    Nov 8, 2012
    Posts:
    118
    Will try to repro/submit later if I have time.
     
    Jodon and karl_jones like this.
  14. TomPo

    TomPo

    Joined:
    Nov 30, 2013
    Posts:
    56
    Hi
    Just sent an bug report with this error.
    Almost empty scene while testing HD Pipeline with 2018.2.0f2
    Target Texture field under Camera Output Settings is empty of course
     
    Last edited: Jul 13, 2018
    OfficialHermie likes this.
  15. mephistonight

    mephistonight

    Joined:
    Dec 14, 2016
    Posts:
    43
    Would you mind linking your issue number so I can also track it please?
     
  16. OfficialHermie

    OfficialHermie

    Joined:
    Oct 12, 2012
    Posts:
    409
    I've filed a bug report.