using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.IO; public class TakeScreenshot : MonoBehaviour
{
[Header("Managers")]
public GameObject SM; private bool isProcessing = false;
public float startX;
public float startY;
public int valueX;
public int valueY; public void shareScreenshot()
{ if (!isProcessing)
StartCoroutine(captureScreenshot());
} public IEnumerator captureScreenshot()
{
isProcessing = true; //Wait for 1 second while we close the shop panel
//ui change do here
yield return new WaitForSeconds(); yield return new WaitForEndOfFrame(); Texture2D screenTexture = new Texture2D(Screen.width, Screen.height); screenTexture.ReadPixels(new Rect(, , Screen.width, Screen.height), , ); // apply
screenTexture.Apply(); //------------------------------------------------------- PHOTO byte[] dataToSave = screenTexture.EncodeToPNG(); string destination = Path.Combine(Application.persistentDataPath, System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png"); File.WriteAllBytes(destination, dataToSave); if (!Application.isEditor)
{
// block to open the file and share it ------------START
AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse", "file://" + destination);
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), "");
intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "");
intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");
AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity"); // option one WITHOUT chooser:
currentActivity.Call("startActivity", intentObject); // block to open the file and share it ------------END }
isProcessing = false; }
}

unity share current game screen的更多相关文章

  1. Capture Current Soft Screen

    Bitmap memoryImage; private void CaptureScreen() { Graphics myGraphics = this.CreateGraphics(); Size ...

  2. Unity Flow distort of screen

    Shader "ScreenWater" {Properties { _MainTex ("Base (RGB)", 2D) = "white&quo ...

  3. 在Unity中实现屏幕空间反射Screen Space Reflection(4)

    第四部分讲一下如何在2D屏幕空间步进光线. http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html 中的代码感 ...

  4. screen space shadowmap unity

    unity用到了screen space shadow map 1.camera 在light pos 生成depth1 2.screen space depth2 3.根据depth1 depth2 ...

  5. BEST FREE UNITY ASSETS – OVER 200 CURATED QUALITY ASSETS

    http://www.procedural-worlds.com/blog/best-free-unity-assets-categorised-mega-list/ BEST FREE UNITY ...

  6. ubuntu Screen 的比较详细的命令

    Linux Screen Commands For Developers 转自:http://fosshelp.blogspot.com/2014/02/linux-screen-commands-f ...

  7. Overview over available Turtle and Screen methods

    24.5.2.1. Turtle methods Turtle motion Move and draw forward() | fd() backward() | bk() | back() rig ...

  8. 实操UNITY3D接入91SDK安卓版

    原地址:http://bbs.18183.com/thread-149758-1-1.html 本文内容为创建UNITY3D接入91SDK的DEMO的具体操作过程.本人水平有限,UNITY3D与And ...

  9. Unity-WIKI 之 AnimationToPNG

    组件功能 把3D角色的动画录制成PNG一帧一帧输出,这是一个件多么美好的事! 可能遇到问题 有可能当你新建完脚本时会出现下面的错误: `System.IO.File' does not contain ...

随机推荐

  1. Linux学习总结(八)-磁盘格式化,挂载,swap扩容

    上次我们学习了磁盘分区,磁盘分区完后还不能直接使用,需要对分区进行格式化,载入某个类型的文件系统,然后挂载到相应目录下才可使用. 一 磁盘格式化 格式化命令: mke2fs -t [ext2 ext3 ...

  2. 开关WI-Fi显示列表

    实现效果: 使用方法: Show-NetList     #显示Wi-Fi列表 Show-NetList -off #关闭显示 (如图) 实现代码: function Show-NetList { P ...

  3. 【转】Spring Boot特性

    https://yq.aliyun.com/articles/25530 摘要: 1. SpringApplication SpringApplication 类是启动 Spring Boot 应用的 ...

  4. 作为测试新手,web测试从何开始学起?

    我们先来弄清楚web测试的测试范围,通常web测试包含:功能测试.性能测试.浏览器兼容测试.安全测试以及用户界面测试等.那么,作为一个初级测试员或者实习测试员,最开始的能做的只能是功能测试和用户界面测 ...

  5. LeetCode 中级 - 重新排序得到的幂(105)

    从正整数 N 开始,我们按任何顺序(包括原始顺序)将数字重新排序,注意其前导数字不能为零. 如果我们可以通过上述方式得到 2 的幂,返回 true:否则,返回 false. 示例 1: 输入:1 输出 ...

  6. ubnutu 安装protocol buffer

    工作中需要使用protocol buffer,需要编译出protocol buffer的动态链接库,然后在别的makefile中链接它, 我的环境是ubnutu16.04,64bit,使用的proto ...

  7. mysql 8.0.12 日常出错

    最近不知道怎么回事,数据库老是会输出一个: [Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and co ...

  8. python字符编码转换说明及深浅copy介绍

    编码说明: 常用编码介绍: ascii 数字,字母 特殊字符. 字节:8位表示一个字节. 字符:是你看到的内容的最小组成单位. abc : a 一个字符. 中国:中 一个字符. a : 0000 10 ...

  9. 简单json---转树形json

    var data = [ {"fileName":"navone","layFilterId":"layadmin-system- ...

  10. 扩展运算符及其在vuex的辅助函数里的应用详解

         一.扩展运算符   <1>为什么扩展运算符会诞生?              因为箭头函数没有arguments,所以才有了扩展运算符       <2>在箭头函数里 ...