Search Unity

Add a scene into another scene (kind of overlay) ?

Discussion in 'Getting Started' started by ZenLulz, Nov 14, 2017.

  1. ZenLulz

    ZenLulz

    Joined:
    Sep 10, 2014
    Posts:
    1
    Hi there !

    I'm searching for a while on the forums and Google and could not figure out if this is possible using Unity. Basically, I have built a game in one scene (let's call it gameScene). I use a device that recognizes my hand and the gameplay of the game is based on the movements I'm doing. The SDK of the device provides another scene where I can see my hand with fingers (let's call it handScene).

    What I would like is to ability to play my game in gameScene while having a little overlay/area (I'm not sure if there is another word for that) that would display the handScene inside, so I can visually demonstrate that I can read to movement of the hand to interact with the game.

    Naturally, I would call that inserting a scene inside another, but I'm sure this is not the right vocabulary, since I could not find any helpful resources out there.

    Many thanks for you help !

    Cheers
     
  2. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,147
    Unity usually refers to it as multi-scene. Here is the document entry for editing multiple scenes.

    https://docs.unity3d.com/Manual/MultiSceneEditing.html

    For loading them at runtime you'd use the SceneManager but with LoadSceneMode set to Additive. You can load them, set them active/inactive, unload them, and so on through the SceneManager.

    https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.html
     
    yeonsh and tjbarrott like this.
  3. alanjoskowicz23

    alanjoskowicz23

    Joined:
    Dec 24, 2020
    Posts:
    1
    Hi @ZenLulz !
    I know it has been some years since you posted this, but I was wondering if you figured out a way of doing so. For what I understood you wanted a scene to render ontop of another scene and at the same time for both scenes to be running. I am trying to do the same thing (if what you were trying to do was what I described). Either way, do you know of a way that I could do that?
    Thanks a lot!
     
  4. tjbarrott

    tjbarrott

    Joined:
    Jul 27, 2021
    Posts:
    3
    It's been a while, but I just read the article and it fixed the problem. You use scene manager.

    Code (CSharp):
    1. using UnityEngine.SceneManagement;
    2.  
    3. public static class SceneSwitcher
    4. {
    5.     public static void LoadSceneOnTop(Scene scene)
    6.     {
    7.         SceneManager.LoadScene(scene.ToString(), LoadSceneMode.Additive);
    8.     }
    9.  
    10.     public static void UnLoadSceneOnTop(Scene scene)
    11.     {
    12.         int n = SceneManager.sceneCount;
    13.         if (n > 1)
    14.         {
    15.             SceneManager.UnloadSceneAsync(scene.ToString());
    16.         }
    17.     }
    18. }