首页 > 移动平台 > 详细

Unity3d 屏幕截图。并保存。iOS

时间:2014-04-18 09:38:04      阅读:526      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
- ( void ) imageSaved: ( UIImage *) image didFinishSavingWithError:( NSError *)error   
    contextInfo: ( void *) contextInfo  
{  
    NSLog(@"保存结束");  
    if (error != nil) {  
        NSLog(@"有错误");  
    }  
}  
void _SavePhoto(char *readAddr)  
{  
    NSString *strReadAddr = [NSString stringWithUTF8String:readAddr];  
    UIImage *img = [UIImage imageWithContentsOfFile:strReadAddr];  
    NSLog([NSString stringWithFormat:@"w:%f, h:%f", img.size.width, img.size.height]);  
    PhotoManager *instance = [PhotoManager alloc];  
    UIImageWriteToSavedPhotosAlbum(img, instance,   
        @selector(imageSaved:didFinishSavingWithError:contextInfo:), nil);  
}  
bubuko.com,布布扣

 

 

 

 

 

bubuko.com,布布扣
using UnityEngine;  
using System.Runtime.InteropServices;  
   
public class TestSavePhoto : MonoBehaviour  
{  
    [DllImport("__Internal")]  
    private static extern void _SavePhoto(string readAddr);  
   
    private string _cptrAddr;  
   
    private void OnGUI()  
    {  
        if (GUILayout.Button("_SavePhoto!", GUILayout.Height(50), GUILayout.Width(200)))  
        {  
            Debug.Log("_SavePhoto");  
            var readAddr = Application.persistentDataPath + "/" + _cptrAddr;  
            _SavePhoto(readAddr);  
        }  
        if (GUILayout.Button("TakePhoto", GUILayout.Height(50), GUILayout.Width(200)))  
        {  
            Debug.Log("TakePhoto");  
            var cptrAddr = "testpic"; //捕捉地址  
            var readAddr = Application.persistentDataPath + "/" + cptrAddr;//读取地址,这两个地址在iOS里不一样  
            Debug.Log("cptr:" + cptrAddr + ", read:" + readAddr);  
            Application.CaptureScreenshot(cptrAddr);  
            _cptrAddr = cptrAddr;  
        }  
    }  
}  
bubuko.com,布布扣

 

Unity3d 屏幕截图。并保存。iOS,布布扣,bubuko.com

Unity3d 屏幕截图。并保存。iOS

原文:http://www.cnblogs.com/qingjoin/p/3671430.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!