- Home /
What is the proper way to hide GUI elements during a screenshot?
I have an iOS app with very simple requirements. Hide some GUI elements (a few buttons and sliders), capture screenshot, and save to iOS "camera roll".
I can get this to work fine when I build with "Development Mode" checked in Build Settings.
The problem arises when "Development Mode" is UNchecked.
The screencapture images are partially black, anywhere from 10-80% of the bottom of the image is completely black. No errors reported.
What I've tried:
Application.captureScreenshot() is asynchronous. As such, you must "poll" the file system to see if the file is "done" being created. I've tried delaying this polling using a simple Invoke() as I thought it might be interfering with the capture.
The ReadPixels() method, but this yields a 100% black image every time in addition to an error in the xCode debug console "OpenGLES error 0x0502 in /xcode_porject/Classes/iPhone_GlesSupport.cpp"
Use 32 Bit Display Buffer as suggested here
Tried WaitForEndOfFrame as defined here and variations of what is here
Initializing capture in LateUpdate.
Attaching screencapture script to camera initializing Application.CaptureScreenshot from OnPostRender. Identical results.
QualitySettings.vSyncCount = 1; in a variety of places, no effect
Delaying the "reenabling" of the gui elements even after Application.CaptureScreenshot coroutine has successfully generated image file discovered in poll to System.IO.File.Exists(). No effect.
I am at a COMPLETE LOSS as to the solution. 3 weeks of development, the project was finished, go to build beta distribution, uncheck "Development Mode" and the project comes to a crashing halt.
Is this a Unity for iOS Bug?
I have a Game$$anonymous$$anager instance I made to manage game state. There are multiple GUI elements on OnGUI across a handful of Components. $$anonymous$$y game manager instance is accessed by these components by a public bool property named guiEnabled. In these components, OnGUI simply checks game$$anonymous$$anager.guiEnabled to deter$$anonymous$$e whether the element(s) are displayed.
Did you manage to solve this issue? I'm struggling with this problem right now...
Answer by ScroodgeM · Aug 30, 2012 at 09:24 PM
try to enable VSync, this should not let capturing screenshot while frame rendering
try to make screenshot in this method
also you can create rendertexture, render camera once to this rendertexture, read pixels, copy it to texture2d and save it as file
also try this example
Scroodge, thanks I will poke around with that. I updated my question adding a #4 as I forgot that I already tried WaitForEndOfFrame in a Coroutine.
Also, RenderTexture class is only available in Unity Pro and I only have Unity with iOS Basic.
I'm currently trying #2. #1 was a bit confusing to me as the docs leave a bit to be desired. Can that property be set anywhere?
yes it can be set from QualitySettings
http://docs.unity3d.com/Documentation/Components/class-QualitySettings.html
Answer by Kryptos · Aug 31, 2012 at 08:35 AM
Use a camera that does not render the GUI layer. You can also change the culling mask temporarily.
Your answer
Follow this Question
Related Questions
Splashscreen problem on iOS 0 Answers
How can you hide "Development Build" text? (without unchecking) 0 Answers
Xcode Problem (Whats Wrong With My Code) 1 Answer
Unity IL2CPP 0 Answers
HUGE Texture problems on iPhone when using animated UVs 2 Answers