- Home /
How to load a scene within a scene
This has been asked before, but none of the answers I have seen have answered my own.
I have 2 Scenes: Scene1 and Scene2
Scene1: Basic indoor living room with amenities couch etc. Huge Flatscreen on TV stand, with an Xbox360 underneath.
Scene2: My own finished game.
(This is for a Virtual Environment Final for College, we need to make a "real-life" sim, where we do everyday tasks/hobbies. What I have chosen is to have the player walk and turn on the Xbox360 and then put in the disc and sit down to play a game)
What I want to do is when the player presses the play button I am going to pan the camera so that you still see the TV and the background surroundings, yet Scene 2 is playing on the TV.
How would I go about changing the resolution of Scene2 to be smaller than Scene1, while still being able to see the background of scene1
I know with all of the Application.LoadLevelAdditive and Application.LoadLevelAdditiveAsync load in other assets into the scene without deleting the current ones, but I dont want to load in the "Scene" view of the Scene2, I want the Game "View" only to be loaded onto a certain resolution (Which i would make fit into the exact dimensions of the TV Screen)
Would it be possible to load in Scene2 or somehow have it running within Scene1 and just turn it on when the player turns on the Xbox.
Also, when the player dies in the game, I would want to just reload the scene on the TV.
Im not asking for any of you to do this for me, what I want is for someone with knowledge to point me in the right direction, I've been scouring the Unity Script Reference for something that "might" pertain to what I want to do, but, it is hard to find something when I am not exactly sure what it is lol
Sorry for such a long post
Thanks for spending the time to read this, and I appreciate any help you provide!
If all else fails, I will just pan the screen into the size of the TV while fading to Black and then switch the scenes
Answer by Jeff-Kesselman · May 05, 2014 at 02:03 AM
Um, first off, if its all on screen at once, its all one scene.
If you really want to do this then you will have to have both scene graphs loaded. You will need to put them on different layers and set the main camera to render the layer the room is on and not the one the game is on. Then you will need to put the game somewhere else in the world where it wont interact with the room model. You will need to set up a second camera that renders the layer the game is on to a texture, and map that texture to the TV in the first model.
Render to texture only is available, btw, in Unity Pro.
If I might suggest a different approach....
(1) Capture a fixed image of the start of the game and make that the texture of the TV screen.
(2) Capture an image from standing in front of the TV screen. Bring that into a paint program and remove the screen so you have a "mask" that shows through where the screen is.
(3) Make a separate scene that is for your gameplay with that mask as a gui Texture.
(4) Move the player to the matching position in the room scene, then transfer to the game scene.
Yes being that I am a student, I do not have access to Unity Pro while at home (Which is where 99% of my work is done)
So using the workaround method you are talking about, After creating the mask, how would I set the game scene to render at 1024x768 (Exact size of the TV Screen) while having the mask applied to a total screen size of say for example 1280x1024.
Or would your method mean that I should just move my game scene cameras further back and apply the mask so that it cuts off the actual game screen itself.
Thank you alot for your answer, $$anonymous$$morow I will be at college and will try to set up a Render to texture method, unless there is a scripted method to set the entire game scene window size seperate from the total screen size.
Thanks again for your time
There's also a workaround where you have the camera rendering the game scene on the tv on a higher layer than the living room camera and a depth mask object with a cutout rendering on the layer above that, and then mess with the top camera's projection matrix to match the perspective of the TV screen; but good luck with that...
What I mean is, set your camera to the right place in your scene to get the static view of the TV for the mask. Its the same palc you will move the camera to before switching scenes.
Take a screen shot.
$$anonymous$$odify in a 2D graphics program sucha s photoshop to remove the screen contents. Then save it at whatever resolution/aspect ratio you will use for the playing scene.
So the other night I went through the 'extreme' trouble of attempting to set up the scene using a multiple camera setup and changing the depth of the camera at a certain point based off of 4x4 matrices, then spent 8 hours scripting 4x4 matrices. Then another 2 hours playing with RenderTextureFree, only to find out the free work around bums off the CPU, so basically running it anything faster than 0.1 dropped the game past playability.
So with all doubt, and little sleep, I went to college the next morning and decided I'd play around with the Pro version RenderTexture.
With 3 clicks I had accomplished what I had spent about 10 hours on the night before. I was a little irritated at how easy it was to accomplish, not to mention the Pro version running off the GPU meant I could run the game perfectly on the TV screen.
So thank you for the information! I highly recommend nobody try to even mess with RenderTextureFree, as Unity has done quite a good job at forcing people to use Pro.
Personally I feel if you have the knowledge to make your own workaround, you should be allowed to do so.
But then again, business is business.
Again thank you for the information! :D
Your answer
![](https://koobas.hobune.stream/wayback/20220613144249im_/https://answers.unity.com/themes/thub/images/avi.jpg)