public static IEnumerator ShareBattleResult(string type) { int w = Screen.width * 50 / 640; int h = Screen.height * 57 / 360; Rect rect = new Rect(w, h, Screen.width - w * 2, Screen.height - h * 2); string filepath = Application.persistentDataPath + "/battleresult.png"; Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false); //只在每一帧渲染完成后才读取屏幕信息 yield return(new WaitForEndOfFrame()); //读取屏幕像素信息并存储为纹理数据 screenShot.ReadPixels(rect, 0, 0); screenShot.Apply();// 这一句必须有,像素信息并没有保存在2D纹理贴图中 //读取将这些纹理数据,成一个png图片文件 byte[] bytes = screenShot.EncodeToPNG(); //写入文件 并且指定路径,因为使用该函数写入文件,同名的文件会被覆盖,所以,在路径中使用Time.time只是为了不出现同名文件而已, 没有什么实际的意义,只是当作个测试 File.WriteAllBytes(filepath, bytes); //分享 if (type == "wxtimeline") { PlatformDifferences.WXShareToTimeline("", "", "", filepath); } else if (type == "wxsession") { PlatformDifferences.WXShare("", "", "", filepath); } else { PlatformDifferences.QQShare("", "", "", filepath); } }
void onQQYQ(GameObject g) { PlatformDifferences.QQShare(Session.CurrentUser.Name + "邀请你加入团队", "", "http://shouji.baidu.com/software/10526673.html", "http://47.90.21.98:8080/Images/lemon.png"); }
void OnBtnInviteFriendClicked(GameObject sender) { SoundManager.Instance.PlaySound("音效/按钮"); PlatformDifferences.QQShare("一起来玩吧", "卡五梅", "http://www.baidu.com", "http://img3.cache.netease.com/photo/0005/2013-03-07/8PBKS8G400BV0005.jpg"); }
void BtnShareQQButtonClicked(GameObject sender) { SoundManager.Instance.PlaySound("音效/按钮"); PlatformDifferences.QQShare("快来一起玩吧", "房间号" + BattleCode.text, "http://www.kawumei.com/", "http://www.kawumei.com/"); }