Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by jpthek9 · Feb 25, 2015 at 12:11 AM · camerafreezescreenshotframe

How do I freeze the camera frame?

In certain scenarios in my game, I'd like to freeze the camera and stop all rendering but still show the last rendered frame.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
7
Best Answer

Answer by jpthek9 · Feb 25, 2015 at 06:42 AM

The answer was pretty simple and intuitive but had some intuitive quirks. To freeze the camera, I had to set both the clear flags and culling mask to nothing so that the last rendering wouldn't be cleared and nothing new would be rendered. I couldn't set both on the same frame however, as the camera apparently needs time to render with the new settings so a coroutine did the trick:

 IEnumerator FreezeCam()
 {
         //yield return null;
     Camera.main.clearFlags = CameraClearFlags.Nothing;
     yield return null;
     Camera.main.cullingMask = 0;
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Landern · Feb 25, 2015 at 12:20 AM

Pro

Application.CaptureScreenshot and Graphics.Blit

Non-Pro

Application.CaptureScreenshot and the method Camera.OnRenderImage

forget about the source and just stuff your screenshot texture as the destination parameter or forget about capturing a screenshot and use the source texture in OnRenderImage method, stuff that in some variable for current and future use, apply that as the destination until freeze frame has elapsed.

Either Pro or Free:

Screenshot Create a quad put it as a child to the camera, but ensure it's properly distanced and all that jazz. Enable Quad, put screenshot on quad.

Profit.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jpthek9 · Feb 25, 2015 at 12:46 AM 0
Share

Ah, thanks. I was hoping for something more intuitive and efficient though as the tasks I'll be perfor$$anonymous$$g while the camera is paused are demanding. Is it possible to just pause the camera on its last rendering?

avatar image
0

Answer by Tibor-Udvari · Jan 05 at 08:36 AM

I had a black screen on iOS metal with the ClearFlags approach. I managed to get it working with a temporary render texture. Attach this to your main camera doing the rendering. Then you just set the pause value, and celebrate.

 public class CameraPause : MonoBehaviour
 {
     [SerializeField] private RenderTexture _cachedRenderTexture;
     public bool paused;
 
     public static CameraPause instance;
 
     private void Awake()
     {
         instance = this;
     }
 
     void OnRenderImage(RenderTexture src, RenderTexture dest)
     {
         if (_cachedRenderTexture == null)
         {
             _cachedRenderTexture = new RenderTexture(src.width, src.height, src.depth);
         }
 
         if (paused)
         {
             Graphics.Blit(_cachedRenderTexture, dest);
         }
         else
         {
             Graphics.CopyTexture(src, _cachedRenderTexture);
             Graphics.Blit(src, dest);
         }
     }
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Pangamini · Jan 05 at 01:45 PM 0
Share

Would it not be enough to just disable the camera?

avatar image Tibor-Udvari · Jan 05 at 01:47 PM 0
Share

No, that would completely turn off the rendering. In my use case I needed to sample the cached render texture data.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Specifying a camera using ScreenShotMovie and changing capture rate while not affecting playback rate 1 Answer

Take screenshot of pixels OUTSIDE the game window? 0 Answers

Camera Change Bug 0 Answers

how to preview screenshot immediately after its taken ?? 0 Answers

Open screenshot in file location Android 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges