Search Unity

Pop up scene window within the same scene?

Discussion in 'Scripting' started by FreshCoder-731319, Jun 11, 2020.

  1. FreshCoder-731319

    FreshCoder-731319

    Joined:
    May 21, 2020
    Posts:
    17
    Is there any tutorials or steps i could follow in order to get a pop up scene window within another scene?

    I have got two different scenes within my unity project, i want the user to be able to select a button which will then be prompt with another pop up of another scene in the same window.
     
  2. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    You'll definitely need to load the new scene additively for starters.

    To show one camera as a "scene window" you'll probably want to make the camera render into a RenderTexture, then apply that RenderTexture to a RawImage component in your UI. Alternately, you can change the camera's viewport rect to render to a smaller section of the screen (if so, you'll need to play with your cameras' "Depth" numbers to get them to render on top of each other correctly.)

    Then comes the hard part. Very likely, your two scenes will now be sort of "merged", both rendering and existing and interacting in the same space at the same time. You'll need to do something to prevent that, and there is no builtin way to separate them. You can move them to different positions so they're not overlapping, you can use layers, etc. Whatever you do, will have to be your own solution based on the contents of your scenes.
     
  3. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    This is a bit fiddly to set up but will pay huge dividends the more popup screens you have, because you can keep them all safely apart from each other in scenes.

    To see a functioning example, check out my Datasacks module. If you run the
    game1
    scene and hit the
    popup1
    button, it triggers the loading of an overlay window from a scene, then the subsequent unloading when you dismiss it.

    All the functionality is driven through my datasack module, which I use for all my UI interoperation, in order to avoid tons of easily-broken drag-and-dropping of UI crud through the editor.

    Datasacks is presently hosted at these locations:

    https://bitbucket.org/kurtdekker/datasacks

    https://github.com/kurtdekker/datasacks

    https://gitlab.com/kurtdekker/datasacks

    https://sourceforge.net/projects/datasacks/
     
  4. FreshCoder-731319

    FreshCoder-731319

    Joined:
    May 21, 2020
    Posts:
    17
    Thank you i will check it out!
     
  5. FreshCoder-731319

    FreshCoder-731319

    Joined:
    May 21, 2020
    Posts:
    17
    Thanks I will look into this