Search Unity

What does RenderTexture.ReleaseTemporary do?

Discussion in 'Scripting' started by ArachnidAnimal, Oct 20, 2016.

  1. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,832
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    When you create a Rendertexture with gettemporary, releasing it will allow it to be re-used if you happen to need a similar rendertexture in the next couple of frames and if not, it will be destroyed.

    The manual is pretty clear, I think, what is it exactly you're unclear about?
     
    Kiwasi likes this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Unity has an automated object pooling system going on with RenderTextures. GetTemporary and ReleaseTemporary let you tie into this pool.

    Google 'Unity object pool' for a more generic description of why object pools are a good idea, and what they are suited for.
     
    ArachnidAnimal likes this.
  4. ArachnidAnimal

    ArachnidAnimal

    Joined:
    Mar 3, 2015
    Posts:
    1,832
    OK thanks. After re-reading the manuals and looking at some examples I now understand this better.
    "Release" must be object-pooling lingo.