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 can i render a second image to the screen? Like split-screen or mini-map

Discussion in 'Editor & General Support' started by Marscaleb, May 31, 2018.

  1. Marscaleb

    Marscaleb

    Joined:
    Jan 7, 2014
    Posts:
    1,036
    How can I render a second image to the screen?

    I want to have one image drawn on the screen like normal, but then have a second image drawn on part of the screen, like it were part of the HUD.
    I imagine this is a similar thing to drawing a split-screen effect, except that I want one of these images to cover part of the other.

    I'm also curious about how I set up a proper resolution for it and how I can have items rendered in one image but not the other, but I imagine if someone could direct me to the proper name of this feature or any relevant documentation/tutorials, then I could probably find that basic information as well.
     
  2. JAMiller

    JAMiller

    Joined:
    Apr 2, 2009
    Posts:
    78
    RenderTexture is what you're looking for: https://docs.unity3d.com/Manual/class-RenderTexture.html

    You can set up a version of what you describe without any code:

    - Create a Render Texture asset in the project
    - Add second camera in your scene.
    - Plug the render texture into the new camera's 'Target Texture'.
    - You can set up the resolution in Render Texture's inspector.
    - Create a UI RawImage and plug the RenderTexture into it. (Or a 3D Quad with a material using the RenderTexture)

    Control which objects get rendered using Render Layers, and the Culling Mask on the cameras.