Quantcast
Channel: Questions in topic: "xcode"
Viewing all articles
Browse latest Browse all 1047

Getting Unity Screenshot as UIImage in Xcode

$
0
0
Hi all, I'm trying to figure out how to get a screenshot (don't need to save it, just store it in a variable) within xCode (not within Unity). The img variable just returns a white screen, so I'm thinking the code below isn't accessing the right view / window. Does anyone have any ideas how to get the screen as a UIImage within xCode? UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow]; CGRect rect = [keyWindow bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [keyWindow.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

Viewing all articles
Browse latest Browse all 1047

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>