首页 > 其他 > 详细

Unity 截取图片并且显示出来

时间:2014-04-11 08:43:27      阅读:775      评论:0      收藏:0      [点我收藏+]

                                       Unity 截取图片并且显示出来

        近期用到了unity的截图,并且把他显示出来,摸索了很多!

        讲解一个东西,android可以存储一些文件在本地,比如配置文件等!

        对于不同的系统,方法不一!

       

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer)//安卓和IOS
 
          imagePath = Application.persistentDataPath;
 
      else if (Application.platform == RuntimePlatform.WindowsPlayer)//EXE的
 
          imagePath = Application.dataPath;
 
      else if (Application.platform == RuntimePlatform.WindowsEditor)
      {
 
          imagePath = Application.dataPath;
 
          imagePath = imagePath.Replace("/Assets", null);
 
      }

             注意截图命令 Application.CaptureScreenshot("1.jpg");这个会自动存储到相应

 系统的路径中去,也就是上面说的路径!

       IEnumerator SetTexture()
    {
        WWW w = new WWW("file://"+imagePath);//注意必须加file://否则失败
        yield return w;
        if (w.isDone)
        {
            obj.renderer.material.mainTexture=w.texture;
        }
        message = w.error.ToString();
    }

        疑问,我接上了手机却搜索不到1.jpg他跑到哪儿去了呢?

Unity 截取图片并且显示出来,布布扣,bubuko.com

Unity 截取图片并且显示出来

原文:http://www.cnblogs.com/alongu3d/p/3657791.html

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