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

How does the Editor change a RenderTexture size while the game is running?

Discussion in 'Image Effects' started by florianveltman, Jan 31, 2016.

  1. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Hi everybody,
    I was wondering if anyone could point me towards information on how Unity changes the texture size while the game is playing?
    Here's an image of the effect I get when setting the texture size directly in-editor while the editor is in play mode:
    Screenshot 2016-01-31 23.57.39.png
    here's an image of what happens when I set the size before entering play mode:
    Screenshot 2016-01-31 23.57.13.png
    you can see it creates a vertical line in the middle.
    Here's a video where I change the texture size during runtime to show the effect it has:

    I'm posting about this because I really like the effect and would like to keep it in some way.

    If I understand it correctly, the texture gets stretched out on the Y axis, while keeping the detail level on the X axis. When setting this through script or directly in the editor, the texture gets compressed on the X axis or something, as to match the Y axis resolution? I guess?
    This is why I would like to know how the editor deals with the size change, to try to reproduce it by scripting the rendertexture's size.

    At any rate, any help I can get will be incredibly useful because I really like that effect!

    Thank you for taking the time to read,
    Florian

    EDIT: Perhaps this thread should not be in this subform and should be moved to the General one. If you have the ability to do so and think that's more appropriate, please do as you think would be best! Thank you!
     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,221
    All the image effects ect we use don't use a render texture asset (like you are here). They create one at runtime.

    What we do is use a pool of them (see RenderTexture.GetTemporary), and then after we have finished we release it :) This means we always have the right size!
     
    andreyefimov2010 likes this.
  3. florianveltman

    florianveltman

    Joined:
    Sep 7, 2012
    Posts:
    27
    Thanks for the answer Tim, I'll have a look and see if I can use that instead, and if I can reproduce the effect!