- Home /
How to pause the main camera ?
Would anyone have any idea how to pause ( not disable) the main camera view ? I have used the timescale (Time.timeScale = 0; ) Class Variables, which only disables the first person control along with other game object in the scene.
The reason why I would like to pause the main camera is because; I do not wish to see any movement when the pause menu GUI is visable.
Answer by SilverTabby · Jul 25, 2011 at 01:57 AM
I would simply pause the game with Time.timeScale = 0, and then do the following commands to Camera.main:
Save the Camera's CullingMask into a variable.
Save the Camera's ClearFlags into a varible.
Set the Camera's ClearFlags to Nothing. This will make it so that the previous frame's image will not be cleared.
Set the Camer'as Culling Mask to 0. This makes it so that NOTHING is rendered.
The Camera should now display the image of the previous frame permanently.
When the game is unpaused, reset the CullingMask and ClearFlags values to what they were before.
Also, when you setup a script to do this, DO NOT use Update or LateUpdate to perform these tasks because they will not be called if the game is paused.
Hope this helped <("<)(^"^)(>")>
Answer by Elecman · Feb 07, 2014 at 05:52 AM
This doesn't work on some mobile devices. For a proper solution, please vote for this: http://feedback.unity3d.com/suggestions/manually-activated-render-loop-for-lower-power-consumption-on-mobile http://feedback.unity3d.com/suggestions/realtime-input-framerate-indepe
Answer by virginiaelizabethgil · Feb 14, 2019 at 07:53 PM
Hello, sorry to reopen this issue so many years after this was solved, I'm having a similar problem with my game and haven't been able to find a solution. I want to completely pause a camera's rendering, and this solution -setting culling mask to 0 and clear flags to nothing- works well except for one detail: when I move the mouse over the area that is paused it leaves a trail behind that will only get cleaned up when the camera is unpaused and its clear flags are reset. From what I understand, this seems to be happening because since the clear flags are set to Nothing, literally nothing will be cleared from the screen. It doesn't seem to be possible to set the flags to the clear the mouse movement only.
This question is a few years old, so I was wondering if perhaps anything been added to Unity that could help me solve this problem. Or is there some other workaround I'm missing?
Thanks in advance for any information!
You might try changing mouse cursor to an empty image maybe? https://docs.unity3d.com/ScriptReference/Cursor.SetCursor.html Just make sure that you figure out the base cursor texture, and rect, so you can reset it back to normal
Hello, thanks for answering! I ended up doing something else: since what I wanted to pause was essentially my 2D background, I separated one camera for the background and one camera for the UI from my main camera. I find that this allows me to save up on update operations, at least in my specific case. Your suggestion however sounds clever and could have been a legit alternative. Thanks again for your time.
Your answer
Follow this Question
Related Questions
Can't use camera.main [SOLVED] 1 Answer
How can i pause gradually from timeScale 1.0 to 0.0 over a second? 1 Answer
How do I pause and unpause multi gameobjects in the scene for a five seconds 1 Answer
Pause the video in unity after playing it but it will done automatically after some time of period. 0 Answers
How to Pause game 1 Answer