【Unity】Android应用程序中分享图片和文字给好友
来源:互联网 发布:大学生陷入网络暴力 编辑:程序博客网 时间:2024/05/17 20:30
插件地址:点此下载插件包【Unitypackage格式】
配置文件中需要添加读写sdcard的权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
using UnityEngine;using System.Collections;using System.IO; public class Share : MonoBehaviour{ public static string imagePath; static AndroidJavaClass sharePluginClass; static AndroidJavaClass unityPlayer; static AndroidJavaObject currActivity; private static Share mInstance; public static Share instance { get{ return mInstance;} } void Awake () { mInstance = this; } void Start () { imagePath = Application.persistentDataPath + "/HKeyGame.png"; sharePluginClass = new AndroidJavaClass ("com.ari.tool.UnityAndroidTool"); if (sharePluginClass == null) { Debug.Log ("sharePluginClass is null"); } else { Debug.Log ("sharePluginClass is not null"); } unityPlayer = new AndroidJavaClass ("com.unity3d.player.UnityPlayer"); currActivity = unityPlayer.GetStatic<AndroidJavaObject> ("currentActivity"); } public void CallShare (string handline, string subject, string text, bool image) { Debug.Log ("share call start : " + imagePath); if (image) { sharePluginClass.CallStatic ("share", new object[] { handline, subject, text, imagePath }); } else { sharePluginClass.CallStatic ("share", new object[] { handline, subject, text, "" }); } Debug.Log ("share call end"); } public void ScreenShot () { StartCoroutine (GetCapture ()); } IEnumerator GetCapture () { yield return new WaitForEndOfFrame (); int width = Screen.width; int height = Screen.height; Texture2D tex = new Texture2D (width, height, TextureFormat.RGB24, false); tex.ReadPixels (new Rect (0, 0, width, height), 0, 0, true); byte[] imagebytes = tex.EncodeToPNG ();//转化为png图 tex.Compress (false);//对屏幕缓存进行压缩 // image.mainTexture = tex;//对屏幕缓存进行显示(缩略图) File.WriteAllBytes (Application.persistentDataPath + "/HKeyGame.png", imagebytes);//存储png图 Debug.Log (Application.persistentDataPath); }}
0 0
- 【Unity】Android应用程序中分享图片和文字给好友
- Android应用实现微信分享(微信好友,朋友圈),分享链接,图片,文字
- JList中加载图片和文字,实现好友列表
- QQ分享本地图片给好友
- Android 文字和图片分享功能
- android分享图片文字
- android实现分享给好友功能
- android实现分享给好友功能
- android实现分享给好友功能
- android实现分享给好友功能
- android实现分享给好友功能
- android应用中分享到微信好友和朋友圈的实现
- android秒启动unity,和给unity添加过渡图片
- Android APP中跳转至微信,分享图文给好友或者朋友圈(加跳转QQ好友或QQ群)
- Android给图片加文字和图片水印
- Android给图片加文字和图片水印
- Android给图片加文字和图片水印
- android中给一个Button添加图片和文字的方法
- 检测网页是否通过W3C标准的校验
- 找到netstat的程序的名称
- Android系统性能调优工具介绍
- ORA-01591: 锁被未决分布式事务处理解决方案
- 中国CDN行业,谁主沉浮?
- 【Unity】Android应用程序中分享图片和文字给好友
- mtk 驱动笔记 lcd camera led tp
- 关于防盗链和镜像源的域名配置详解。
- 第十六周项目三:max带来的冲突
- Xcode安装插件的方法
- Java NIO系列教程(十一) Pipe
- 第十六周 阅读程序一(3)
- sqlite3_英英词典
- 再谈 最速下降法/梯度法/Steepest Descent