Unity3d 截屏
#pragma strict
function Start () {}
function Update () {}
function ScreenImage(){
Application.CaptureScreenshot("Screenshot.png");
}
2.添加button
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button1 setFrame:CGRectMake(0, 0, 30, 30)];
[button1 addTarget:self action:@selector(ScreenImage) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];
3.响应函数
-(void)ScreenImage{
///调取脚本函数
UnitySendMessage("ARCamera","ScreenImage","");
//保存到相册
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains( NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *filePath2 = [documentsDirectory stringByAppendingPathComponent:@"Screenshot.png"];
UIImage *image = [UIImage imageWithContentsOfFile:filePath2];
UIImageWriteToSavedPhotosAlbum(image,nil, nil, nil);//保存
}
文章来源: zzzili.blog.csdn.net,作者:清雨小竹,版权归原作者所有,如需转载,请联系作者。
原文链接:zzzili.blog.csdn.net/article/details/8265521
- 点赞
- 收藏
- 关注作者
评论(0)