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 ...
随机推荐
- Avito Cool Challenge 2018 E. Missing Numbers 【枚举】
传送门:http://codeforces.com/contest/1081/problem/E E. Missing Numbers time limit per test 2 seconds me ...
- ElasticSearch5.0+版本分词热更新实践记录
前言 刚开始接触ElasticSearch的时候,版本才是2.3.4,短短的时间,现在都更新到5.0+版本了.分词和head插件好像用法也不一样了,本博客记录如何配置Elasticsearch的Hea ...
- Multiply Strings 字符串相乘
http://www.cnblogs.com/TenosDoIt/p/3735309.html https://blog.csdn.net/fly_yr/article/details/4805561 ...
- __future__模块
Python提供了__future__模块,把下一个新版本的特性导入到当前版本,于是我们就可以在当前版本中使用一些新版本的特性,比如除法: 在Python 2.x中,对于除法有两种情况,如果是整数相除 ...
- 【题解】洛谷P4391 [BOI2009] Radio Transmission(KMP)
洛谷P4391:https://www.luogu.org/problemnew/show/P4391 思路 对于给定的字符串 运用KMP思想 设P[x]为前x个字符前缀和后缀相同的最长长度 则对于题 ...
- C++重载操作符operator
operator是C++关键字,用于对C++进行扩展: 1.可以被重载的操作符:new,new[],delete,delete[],+,-,*,/,%,^,&,|,~,!,=,<,> ...
- Unity透明视频播放 所需的Shader脚本
Shader "Custom/ShaderMovie" { Properties { _MainTex("Color (RGB)", 2D) = "b ...
- ABAP术语-SAP GUI for HTML
SAP GUI for HTML 原文:http://www.cnblogs.com/qiangsheng/archive/2008/03/14/1104996.html An ITS impleme ...
- Flask入门数据库的查询集与过滤器(十一)
1 查询集 : 指数据查询的集合 原始查询集: 不经过任何过滤返回的结果为原始查询集 数据查询集: 将原始查询集经过条件的筛选最终返回的结果 查询过滤器: 过滤器 功能 cls.query.filte ...
- JavaScript 中 Property 和 Attribute 的区别详解
property 和 attribute非常容易混淆,两个单词的中文翻译也都非常相近(property:属性,attribute:特性),但实际上,二者是不同的东西,属于不同的范畴. property ...