Forum rules - please read before posting.

Camera Fade - Want to fade everything but leave subtitles visible

AC Ver: 1.75.2
Unity Ver: 2019.4.35f1

Hello,

I have a situation where I want to fade out the camera, but leave player subtitles visible.

What would be the best practice way to do this?

Comments

  • The default fade effect is drawn using Unity's ImGUI system, which comes last in the "render order" for a frame.

    To have control over its drawing order relative to specific menus, you'd have to replace the default fade effect with your own.

    To do this using Unity UI, create a new UI canvas that draws a single Image across the screen (to act as a custom fade effect). Then, uncheck Draw fade? in the MainCamera Inspector, and have a script apply its GetFadeAlpha value to e.g. a Canvas Group component's Alpha property.

    Having the Subtitle menu show over it is then a case of giving the Subtitles UI prefab a higher "Sort Order" value on its Canvas.

  • Thanks Chris. I think I might have dabbled with this in the past. Sounds familiar.

    Sort of a related question, is there a reason why "Fade In" doesn't have an option for a custom texture?

  • If you're fading in, then it's assumed that the texture is already displaying full-screen - in which case, changing the texture at this point wouldn't typically be common.

  • RemRem
    edited April 2022

    The way I do this: I place a big black square sprite on top of everything with its visibility set to false. I use camera: fade out command in AC, then switch the black sprite on, fade camera in instantly (player can't see any change here cos it goes from black to black) and then I have subtitles displayed on top of that black sprite.

  • edited April 2022

    So I've been digging around in my scene and there's definitely some old setup which makes this work. The trouble is, I don't understand why it's working (the other occasional development problem!)

    Here's the setup:

    The scene has a Unity UI canvas that is a raw image stretched across the screen:

    On the canvas, there is a script:

    I'm not sure where this script has come from. I don't recall writing it. The script is taking the fade texture and fade alpha of the camera (defined in the fade action I assume) and plugging that into the UI objects.

    And sure enough, it works:

    I don't understand why though because the sort order of this fade canvas and the subtitle canvas is the same, so shouldn't the fade be drawing on top of everything?

  • If the Sort Order is the same, then the order will be down to something less tangible, e.g. the order in which Unity processes objects in the Hierarchy. It may work here, but may not on other machines/platforms. You should adjust the Sort Orders manually to be sure it's always correct.

  • edited April 2022

    Definitely a good shout. I've bumped up the subtitle canvas sort order for robustness. I also solved the mystery of where the script came from. Looks like I took it from here a long time ago: https://adventure-creator.fandom.com/wiki/Fading_with_Unity_UI

    I have noticed if I pause while the fade is occurring, then it'll interrupt and clear it:

    Is there a way to have it preserve and resume the fade if the pause menu is triggered?

  • Is there a way to have it preserve and resume the fade if the pause menu is triggered?

    In the Camera: Fade Action, set the Behaviour when paused field to Hold.

  • Perfect. For some reason, my eyes had never registered that option before.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.