Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Rendering two scenes at once

Discussion in 'General Graphics' started by nickhudson2244, Nov 25, 2023.

  1. nickhudson2244


    Mar 18, 2019
    I am going to preface this by saying I know this is an odd ask. It is for a niche (non-game) project. And this is a feature I am considering exploring. The project is basically unity inside unity. So the user can create scenes, transition between scenes, etc. Our scenes simulate unity scenes but are not actually unity scenes. You can basically think of them as a parent object, with children. Pretty much the same as unity scenes. Note all of this is done in a single "Unity" scene.

    When the user switches from one scene to another, the first scene parent object is disabled, and the new scene parent object is enabled.

    Here is a basic example of what I would like to achieve. SceneA has a single camera and a single cube moving back and forth. SceneB has the same. Both cameras output to a texture.

    I would like to be able to have both textures showing at once, both showing the cube moving back and forth.

    Solutions I have considered:

    1. Assigning layers to every object in the scene, specific to that scene. And then use layer masks so camera in SceneA only shows objects in SceneA. With this solution, hypothetically, the two scenes could be placed on top of each other without issue. The worry with this solution is what about scene sounds, collisions, etc.

    2. Assign scenes their own "rendering area". Say SceneA renders from 0 to 1000 on the X and 0 to 1000 on the Y. And SceneB renders from 1000 to 2000 on the X and 1000 to 2000 on the Y. The obvious issue with this is running into floating point accuracy at far distances. And having to limit scene size. And having to worry about scene boundaries being followed.
    Would love to hear opinions!