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. yii2.0 在save保存之前的操作(放在模型model文件内)

    public function beforeSave($insert){ if(parent::beforeSave($insert)) { if($insert) { } else { } retu ...

  2. Selenium应用代码(读取mysql表数据登录)

    1. 封装链接数据库的类: import java.sql.ResultSet; import java.sql.Connection; import java.sql.DriverManager; ...

  3. 关于ucos操作系统中如何从邮箱中提取出消息

    问题提出? 定义两个任务,task1,task2,想task1用OSMboxPost,task2用OSMboxPend定义了一个邮箱Mbox1=OSMboxCreate(括号里面应该怎么写?)还有具体 ...

  4. Java 编码规范(转)

    本文转自:http://www.javaranger.com/archives/390 文章总结出了java编码过程中的一些规范,以便参考. 1.合理组织代码层次,分层清晰:controller.lo ...

  5. css代码添加背景图片常用代码

    css代码添加背景图片常用代码 1 背景颜色 { font-size: 16px; content: ""; display: block; width: 700px; heigh ...

  6. day 03 --Haproxy 增加, 删除,查询

    key 知识点:函数的定义, 函数的递归调用, flag 标志位的使用,eval() 函数 #!C:\Program Files\Python35\bin # -*- conding:utf-8 -* ...

  7. 我的前端工具集(六)Ajax封装token

    我的前端工具集(六)Ajax封装token   liuyuhang原创,未经允许禁止转载 在单点登陆中,或登陆验证后,不应该每次都验证用户名和密码, 也不应该将用户名密码存入cookie中(虽然很多都 ...

  8. 浅析Vue原理(部分源码解析)

    响应式 Object.defineProperty Object.defineProperty(obj, prop, descriptor) // 对象.属性.描述符 Object.definePro ...

  9. 关于c++随机种子srand( time(NULL) )的设置问题

    设置随机种子srand( time(NULL) ) ,在程序中只需要设置一次就好,而且不能被调用多次,直接看列子. a:每次都重新设置随机种子 #include<iostream> #in ...

  10. 删除文件的第一列 -Linux

    删除文件 text中第一列 方式一 awk '{$1="";print $0}' text 方式二 sed -e 's/[^ ]* //' text