Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Dublicate Canvas (GUI) easy way?

Discussion in 'Scripting' started by stevensen, Mar 11, 2020.

  1. stevensen

    stevensen

    Joined:
    Oct 31, 2013
    Posts:
    7
    Hi there,

    I want to extend a plugin with a other plugin that creates 2 cameras (sidebyside). It works but the gui is not created twice because it is screenspace overlay. Is it possible to duplicate the gui just like that? or is there another way with e.g. shader or render to texture or something like that?
     
  2. APSchmidtOfOld

    APSchmidtOfOld

    Joined:
    Aug 8, 2016
    Posts:
    4,473
    Did you try before asking?
     
  3. stevensen

    stevensen

    Joined:
    Oct 31, 2013
    Posts:
    7
    Thanks for answer/asking.
    I tried to copy the GUI, but it is very complex with many buttons and listboxviews and event system etc. I thought I could scale the gui to half the size and then copy it to the other camera using rendertotexture. But then I would only be able to make half of it clickable.
    So I hoped there is a more general way to make a gui available for 2 camera systems.
     
  4. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    337
    You can have several root canvases in a scene, but I assume you are trying to display them split in the same screen.
    So just keep a single root canvas which has the screen scaler for a simple screen. Then make other child canvases as prefab with all your objects in. I assume you want to display different values in them anyway, so they'd need to be their own instances.
     
  5. stevensen

    stevensen

    Joined:
    Oct 31, 2013
    Posts:
    7
    One problem is that it is a stereopoic plugin. On both cameras the same things should be displayed. If I select something in a listbox it should be shown synchronously on both cameras. Is it possible to use rendertotexture and project only the gui with aplha channel into the other camera? Does anyone have a script with render2texture including the gui?
     
  6. FernandoHC

    FernandoHC

    Joined:
    Feb 6, 2018
    Posts:
    337
    hmm tricky. I tried here render texture but it resulted in a lower quality for some reason (not saying this will happen to you as well), so it is possible.

    But since you want the exact duplicate of the entire result, then I'd suggest trying working everything as you want in a single camera, render that camera to texture. And then have another camera and another canvas that just displays that rendered texture twice, in 2 rawimages. I tried it here and it seems to work, but I don't have your exact scenario so I might be missing something.

    Let me know how it works for you.