Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Bug Flickering image from the previous scene

Discussion in 'Universal Render Pipeline' started by VOXELIUM, Feb 23, 2024.

  1. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    I encountered such a problem.
    After moving to a new scene, a flickering image from the previous scene (menu) is shown in the letterbox areas.

    https://media.giphy.com/media/v1.Y2...ZfYnlfaWQmY3Q9Zw/hr2pCpS5kMJwy4YABL/giphy.gif

    I tried deleting menus gameobjects before loading a new scene,
    and tried clearing the camera after loading a new scene.

    Code (CSharp):
    1.     private void CameraCleaning()
    2.     {
    3.         _camera.clearFlags = CameraClearFlags.SolidColor;
    4.         _camera.clearFlags = CameraClearFlags.Color;
    5.         _camera.clearFlags = CameraClearFlags.Skybox;
    6.         _camera.clearFlags = CameraClearFlags.Depth;
    7.         _camera.backgroundColor = Color.black;
    8.     }
    I show an image (guns and zombies) with a black background before loading the game scene so that the previous camera image is overwritten.
    None of this helps.

    I tried this method before loading a new scene. Did not help.
    Code (CSharp):
    1. GL.Clear(true, true, Color.black);
    I tried this method in Start in a new scene. It only helped once.
    After I returned to the Menu and back into the game scene, the problem returned again, although every time the in game scene Start:
    Code (CSharp):
    1. GL.Clear(true, true, Color.black);
    This problem only exists on iOS, so I think it's a Unity bug.
    What is the reason? How can this be solved?

    Is there any way to contact Unity support? Perhaps only they can solve this problem.

    p.s.
    Sorry, I hid the gameplay of the game in the video because it hasn't been released yet)
     
    Last edited: Mar 10, 2024
  2. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    A likely solution to the problem would be to answer: "Why does the camera in the New Scene retain the image from the previous scene?"
    Where this information stored to delete it?
     
  3. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    have you tried using GL.Clear()?

    your "clearing" confuses me, you're just toggling between several camera settings
     
  4. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    I haven't tried this method
    iknow:
    GL.Clear() requires caution as it is a low-level operation and can affect the operation of other elements of the rendering system. In most cases, it is better to use the standard Unity tools to control background color and other rendering parameters through camera settings and project settings.

    How to use it safely?
     
  5. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    i haven't personally experienced any trouble with gl.clear, but i've only used it in my lightmapper, which is an offline process. my best advice would be try it out and see if you experience any issues.

    i'm pretty sure there's a forum post talking about issues on an ipad, but i can't find it right now
     
    VOXELIUM likes this.
  6. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    At what point do you think I should use gl.clear ?
    Just before loading a new scene?
     
  7. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    either that or right when the new scene starts
     
    VOXELIUM likes this.
  8. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    Thanks for the offer. I'll try and write the result
     
    POOKSHANK likes this.
  9. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    I tried this method before loading a new scene. Did not help.
    GL.Clear(true, true, Color.black);

    I tried this method in Start in a new scene. It only helped once.
    After I returned to the Menu and back into the game scene, the problem returned again, although every time the in game scene Start:
    GL.Clear(true, true, Color.black);
     
  10. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    have you tried putting a black border to cover where this is to maybe make the camera render that instead of blank space? if you already have borders there i really have no clue what's going on, this really isn't something I've seen
     
  11. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    Yes, I do it. Letterboxes are black lines at the top and bottom of the screen to adapt to different screens.

    Is there any way to contact Unity support? Perhaps only they can solve this problem.
     
  12. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    you can file a bug report
     
    VOXELIUM likes this.
  13. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    I solved this problem.

    1 version
    When I exit the menu, I launch an empty scene in which there is a black Overlay that fills the entire screen.
    After this scene, the game scene is already loaded.
    This solves the problem.

    2 version
    It also helps if you run a black Overlay on the entire screen in the game scene and remove it after a second. This method also works, but then it needs to be done in every game scene. I chose the simpler first version for myself.

    It’s very bad that not a single solution for cleaning the camera using code works.
     
    POOKSHANK likes this.
  14. POOKSHANK

    POOKSHANK

    Joined:
    Feb 8, 2022
    Posts:
    366
    i'm glad you could solve it!
     
  15. VOXELIUM

    VOXELIUM

    Joined:
    Nov 24, 2022
    Posts:
    50
    As it turned out, my decision was not permanent.
    The problem that I wrote about repeats itself periodically