Search Unity

Is it possible to play a scene from another scene?

Discussion in 'Scripting' started by Sinci1, Nov 17, 2017.

  1. Sinci1

    Sinci1

    Joined:
    Feb 18, 2016
    Posts:
    53
    Hello, my question is: is it possible to play scene from another scene, what i mean is for example, lets say you make a minigame in one scene, now is it possible to play that in another scene, without copying every object, but that it can regonize input. Hopefully you understand this.
     
    Nabeel001 likes this.
  2. cthomas1970

    cthomas1970

    Joined:
    Sep 12, 2017
    Posts:
    75
    Unity can have multiple Scenes open at once. Try this in the Editor. Put your scenes in an Assets/Scenes folder, and right click on open, Open Additively. You'll now have two scenes open (if you already had one...!)

    You can, if you wish have 10 scenes open. I think in this way, you could, for instance, make a game where the terrain is saved out in Scenes blocks. Not sure if that would work.

    My own prototype game, has a MAIN scene, which contains the general UI, GameManager and whatnot, and I Additively load my Scenes (levels) into this.

    Now, what you seem to want is a GAME within a GAME, thats a different proposition, but with some clever planning and coding, yes, it could be done.
     
  3. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
  4. Sinci1

    Sinci1

    Joined:
    Feb 18, 2016
    Posts:
    53
    Thanks guys, looks like this is what i need, only one question is it possible to scale it? and place it somewhere else?(like in bottom corner) Thanks!
     
  5. cthomas1970

    cthomas1970

    Joined:
    Sep 12, 2017
    Posts:
    75
    Why not give it a try, and let us know? My intuition is, yes.. just ensure that scenes contents are all under a node. You can then scale that now, move it etc, and all its children will move as well.

    My advice is though, avoid scaling things in 3D. Its generally best to model things at their correct size. Working with the children of parents that are scaled, gets really confusing very quickly...
     
  6. cthomas1970

    cthomas1970

    Joined:
    Sep 12, 2017
    Posts:
    75
    BTW, when you do load your other scene, it will need to be Async, to avoid perf issues, you know, your game totally freezing as it loads that file. Because its Async, you will need to setup a callback on the load method, which will then call another func, when load is complete. I found, EVEN WHEN load is reported as complete, that some scene objects may not actually exist yet, I mean you will not be able to Find() them. So using a Co-routine that waits for one of these objects to exist, before proceeding with setup, was my solution to this...