#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);//保存
}