Search Unity

Custom Scene Transitions

Discussion in 'General Discussion' started by Tayd3ll, Dec 13, 2018.

  1. Tayd3ll

    Tayd3ll

    Joined:
    Jun 4, 2015
    Posts:
    13
    Hey guys, I've been working on a few things and i was wondering if it was possible to transition between scenes with animations within the game and not fading to black or having a blank screen. For example, I wanted to have a Book cover be my title screen and then do an animation to open the book to a page that would be my new scene.
    Is it possible to have multiple scenes transition this way or would it make more sense to have 1 scene with the book and animation with different objects being instantiated and uninstantiated depending on what page of the book we are on?

    thanks for any feedback I might get!
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I would fake it with additive loading, animations and render textures.

    Load the new scene in the background, but have its camera direct to a render texture instead of the scene. Then create a book page turning animation, and use your new render texture there. End your animation with the texture fitting the screen exactly. Then redirect the camera output to the screen, and dispose of your animation and previous scene.
     
    Tayd3ll and Murgilod like this.
  3. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,157
    This is the way I always did it, yeah. There's a lot of transitional effects you can pull off this way.
     
    Kiwasi likes this.
  4. Tayd3ll

    Tayd3ll

    Joined:
    Jun 4, 2015
    Posts:
    13
    Awesome thanks guys!
     
  5. macsimilian

    macsimilian

    Joined:
    Sep 19, 2020
    Posts:
    25
    Sorry for the necro post. I am not too familiar with using RenderTextures. How would you make it so that the camera from the loaded scene isn't interfered by stuff in the current scene? Other than by placing the objects in the scenes very far apart.

    Edit: After doing some research I think I may have figured it out, and possibly an even easier solution. You could use a culling mask in the camera settings to differentiate between the two scenes, but this would require iterating over everything in each scene and setting them to specific layers.

    An easier approach without having to deal with multiple loaded scenes: Just take a "screenshot" at the first scene with code like the following:

    Code (CSharp):
    1. RenderTexture renderTexture = new RenderTexture();
    2. Camera.main.targetTexture = renderTexture;
    3. Camera.main.Render();
    4. Camera.main.targetTexture = null;
    Then only the renderTexture needs to survive to the next scene, you can do this by making it static or some other method. Then do the animation with the rendureTexture in the next scene.

    Haven't tried this but should work in theory.
     
    Last edited: Nov 11, 2022