unity share current game screen
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的更多相关文章
- Capture Current Soft Screen
Bitmap memoryImage; private void CaptureScreen() { Graphics myGraphics = this.CreateGraphics(); Size ...
- Unity Flow distort of screen
Shader "ScreenWater" {Properties { _MainTex ("Base (RGB)", 2D) = "white&quo ...
- 在Unity中实现屏幕空间反射Screen Space Reflection(4)
第四部分讲一下如何在2D屏幕空间步进光线. http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html 中的代码感 ...
- screen space shadowmap unity
unity用到了screen space shadow map 1.camera 在light pos 生成depth1 2.screen space depth2 3.根据depth1 depth2 ...
- 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 ...
- ubuntu Screen 的比较详细的命令
Linux Screen Commands For Developers 转自:http://fosshelp.blogspot.com/2014/02/linux-screen-commands-f ...
- Overview over available Turtle and Screen methods
24.5.2.1. Turtle methods Turtle motion Move and draw forward() | fd() backward() | bk() | back() rig ...
- 实操UNITY3D接入91SDK安卓版
原地址:http://bbs.18183.com/thread-149758-1-1.html 本文内容为创建UNITY3D接入91SDK的DEMO的具体操作过程.本人水平有限,UNITY3D与And ...
- Unity-WIKI 之 AnimationToPNG
组件功能 把3D角色的动画录制成PNG一帧一帧输出,这是一个件多么美好的事! 可能遇到问题 有可能当你新建完脚本时会出现下面的错误: `System.IO.File' does not contain ...
随机推荐
- 1.Jdeveloper打印出完整日志(-Djbo.debugoutput=console)
有时候在JDeveloper中需要打印出来比较系统和完整的ADF运行时日志 例如,想查看VO当前执行的是哪个View Criteria,运行的完整SQL语句到底如何 以及当前Binding Varia ...
- argsort
argsort函数返回的是数组值从小到大的索引值One dimensional array:一维数组 >>> x = np.array([3, 1, 2]) >>> ...
- 内存修改之IOS版ce
开源工具,算法全部在内存中完成,速度比bmsq,igg快,直接搜索0也是无压力.使用c++编写,有一定的扩展能力,可以自己扩展value type和comparator. 项目地址: https:// ...
- idea debug操作
3. 条件断点 说明: 调试的时候,在循环里增加条件判断,可以极大的提高效率,心情也能愉悦.具体操作: 在断点处右击调出条件断点.可以在满足某个条件下,实施断点. 查看表达式的值(Ctrl + u): ...
- TCP-IP Architecture and IP Packet
Why Internet working? To build a "network of networks" or internet. operating over multipl ...
- C# 对WinForm应用程序的App.config的加密
默认情况下,我们需要对App.config文件里的connectionStrings片断进行加密处理,ASP.NET IIS 注册工具 (Aspnet_regiis.exe)可以胜任这个工作,但这个工 ...
- max-height实现任意高度元素的展开收缩动画
http://dobinspark.com.cn/ 前言: 在说到实现元素的展开收缩,通常的想法是通过控制display的元素属性和none之间的切换,虽然说功能可以实现,但是这种展开是没有任何动画的 ...
- Flask—10-项目部署(02)
项目部署 WEB工作原理 客户端(chrom) <=> WEB服务器(nginx) <=> WSGI(uWSGI) <=> Python(Flask) <=& ...
- weex图片加载更多方法loadmore的使用
首先,放一个weex中loadmore使用的demo,可以看一下http://dotwe.org/vue/8dd2a10c69e149ae8971f8298cc8bebf 1.在list标签上添加 @ ...
- Centos6_32位系统512M内存_如何安装gogs_Mysql_配置开机自启动
因为有很多人的Linux版本比较低,内存配置也较低,X86 ,32位系统的:所以这里推荐采用二进制安装gogs,并且使用Mysql:这个是傻瓜式的安装方案,适合绝大多数人(提及了centos7的安装思 ...