Exemple #1
0
 // 微信分享固定图片
 public void WeChatShareNativeImage()
 {
     //Debug.Log ("----WeChatShareNativeImage----");
     //isWechatCallback = 1;
     if (System.IO.File.Exists(Application.persistentDataPath + "/share.png"))
     {
         //Debug.Log ("----WeChatShareNativeImage----1--");
         Social.DirectShare(Platform.WEIXIN_CIRCLE, "", Application.persistentDataPath + "/share.png", "", "", sharecallbackForRoomcard);
     }
     else
     {
         //Debug.Log ("----WeChatShareNativeImage----2--");
         Social.DirectShare(Platform.WEIXIN_CIRCLE, "", PlayerInfo.Instance.mUrlData.sharePicUrl, "", "", sharecallbackForRoomcard);
     }
 }
Exemple #2
0
    void OnGUI()
    {
        int startheight = 200;
        int heightspace = 200;

        GUIStyle labelstyle = new GUIStyle();

        labelstyle.normal.background = null;
        labelstyle.normal.textColor  = new Color(1, 1, 1);
        labelstyle.fontSize          = 120;
        GUI.Label(new Rect(Screen.width / 2 - 20, 0, Screen.width, 30), "U-Share", labelstyle);
        GUIStyle resultstyle = new GUIStyle();

        resultstyle.normal.background = null;
        resultstyle.normal.textColor  = new Color(1, 1, 1);
        resultstyle.fontSize          = 40;
        GUI.Label(new Rect(0, 100, Screen.width, 60), str, resultstyle);
        GUIStyle buttonstyle = new GUIStyle();

        buttonstyle.normal.background = null;
        buttonstyle.normal.textColor  = new Color(1, 1, 1);
        buttonstyle.fontSize          = 80;

        Social.ShareBoardDismissDelegate dismisscallback =
            delegate()
        {
            Debug.Log("xxxxxx  dismiss");
        };
        Social.ShareDelegate sharecallback =
            delegate(Platform platform, int stCode, string errorMsg)
        {
            if (stCode == Social.SUCCESS)
            {
                Debug.Log("xxxxxx  share success");
                str = "success";
                Debug.Log("直接分享");
            }
            else
            {
                str = "fail" + errorMsg;
            };
        };
        Social.AuthDelegate authcallback =
            delegate(Platform platform, int stCode, Dictionary <string, string> message)
        {
            if (stCode == Social.SUCCESS)
            {
                Debug.Log("xxxxxx message=" + message.Count);
                str = "success";
                foreach (KeyValuePair <string, string> kv in message)
                {
                    string n = kv.Key;
                    string s = kv.Value;
                    str = str + "   " + n + ":" + s;
                }
            }
            else
            {
                str = "fail=";
                foreach (KeyValuePair <string, string> kv in message)
                {
                    string n = kv.Key;
                    string s = kv.Value;
                    str = str + "   " + n + ":" + s;
                }
            };
        };

        if (GUI.Button(new Rect(0, startheight + heightspace * 2, Screen.width / 2, heightspace), "微信登录", buttonstyle))
        {
            Social.Authorize(Platform.WEIXIN, authcallback);
        }
        if (GUI.Button(new Rect(Screen.width / 2, startheight + heightspace * 2, Screen.width / 2, heightspace), "微信分享", buttonstyle))
        {
            Application.CaptureScreenshot("Sceenshot.png");
            Social.DirectShare(Platform.WEIXIN, "Hello World", Application.persistentDataPath + "/Sceenshot.png", "", "", sharecallback);
        }


        if (GUI.Button(new Rect(Screen.width / 2 - 30, startheight + heightspace * 5, Screen.width, heightspace), "打开分享面板", buttonstyle))
        {
            Platform[] platforms = { Platform.QQ, Platform.QZONE, Platform.SINA, Platform.WEIXIN, Platform.WEIXIN_CIRCLE };
            Social.setDismissDelegate(dismisscallback);
            Social.OpenShareWithImagePath(platforms, "Hello World", Application.persistentDataPath + "/Sceenshot.png", "umeng", "http://www.umeng.com/", sharecallback);
        }
//		GUI.color = Color.blue;
//		GUI.backgroundColor = Color.black;
//        if (GUI.Button(new Rect(150, 300, 500, 100), "授权111"))
//        {
//            //接入QQ
//            Social.SetQQAppIdAndAppKey("100424468", "c7394704798a158208a74ab60104f0ba");
//            //授权
//            Social.Authorize(Platform.QQ, delegate(Platform platform, int stCode, string usid, string token)
//            {
//                if (stCode == Social.SUCCESS)
//                {
//                    Debug.Log("授权成功" + "usid:" + usid + "token:" + token);
//                }
//                else
//                {
//                    Debug.Log("授权失败");
//                }
//            });
//
//        }
//
//        if (GUI.Button(new Rect(150, 500, 500, 100), "直接分享"))
//        {
//            //接入QQ
//            Social.SetQQAppIdAndAppKey("100424468", "c7394704798a158208a74ab60104f0ba");
//
//            Social.ShareDelegate callback =
//                delegate(Platform platform, int stCode, string errorMsg)
//                {
//                    if (stCode == Social.SUCCESS)
//                    {
//                        Debug.Log("直接分享");
//                    }
//                    else
//                    {
//                        Debug.Log("直接分享" + errorMsg);
//                    };
//                };
//            //截屏
//            Application.CaptureScreenshot("Sceenshot.png");
//            //分享
//            Social.DirectShare(Platform.QQ, "Hello World", Application.persistentDataPath + "/Sceenshot.png", callback);
//        }
    }
Exemple #3
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(150, 100, 500, 100), "打开分享面板"))
        {
            //按需设置您需要的平台
            Platform[] platforms = { Platform.DOUBAN, Platform.INSTAGRAM, Platform.QQ, Platform.LAIWANG, Platform.SINA };


            //接入instagram
            Social.OpenInstagram();
            //接入QQ
            Social.SetQQAppIdAndAppKey("100424468", "c7394704798a158208a74ab60104f0ba");
            //接入来往
            Social.SetLaiwangAppInfo("laiwangd497e70d4", "d497e70d4c3e4efeab1381476bac4c5e", "");



            //设置分享回调
            //如果无需回调 OpenShareWithImagePath最后一个参数可不填
            Social.ShareDelegate callback =
                delegate(Platform platform, int stCode, string errorMsg)
            {
                if (stCode == Social.SUCCESS)
                {
                    Debug.Log("分享成功");
                }
                else
                {
                    Debug.Log("分享失败" + errorMsg);
                };
            };



            //分享纹理
            //纹理 需要为 ARGB32 and RGB24 格式. 而且纹理的import settings/Advanced下的"Read/Write Enabled"需要勾选
            File.WriteAllBytes(Application.persistentDataPath + "/icon.png", texture.EncodeToPNG());
            //打开分享面版
            Social.OpenShareWithImagePath(platforms, "HelloWorld", Application.persistentDataPath + "/icon.png", callback);
        }
        if (GUI.Button(new Rect(150, 300, 500, 100), "授权"))
        {
            //接入QQ
            Social.SetQQAppIdAndAppKey("100424468", "c7394704798a158208a74ab60104f0ba");
            //授权
            Social.Authorize(Platform.QQ, delegate(Platform platform, int stCode, string usid, string token)
            {
                if (stCode == Social.SUCCESS)
                {
                    Debug.Log("授权成功" + "usid:" + usid + "token:" + token);
                }
                else
                {
                    Debug.Log("授权失败");
                }
            });
        }

        if (GUI.Button(new Rect(150, 500, 500, 100), "直接分享"))
        {
            //接入QQ
            Social.SetQQAppIdAndAppKey("100424468", "c7394704798a158208a74ab60104f0ba");

            Social.ShareDelegate callback =
                delegate(Platform platform, int stCode, string errorMsg)
            {
                if (stCode == Social.SUCCESS)
                {
                    Debug.Log("直接分享");
                }
                else
                {
                    Debug.Log("直接分享" + errorMsg);
                };
            };
            //截屏
            Application.CaptureScreenshot("Sceenshot.png");
            //分享
            Social.DirectShare(Platform.QQ, "Hello World", Application.persistentDataPath + "/Sceenshot.png", callback);
        }
    }
Exemple #4
0
 /// <summary>
 /// 微信分享链接
 /// </summary>
 public void WeChatShareLink(string title, string descripition, string url)
 {
     //isWechatCallback = 1;
     Social.DirectShare(Platform.WEIXIN, descripition, "https://hygg.3399hy.com/pic_resource/HY_NJ_ZQ/" + GlobalData.mHostId + "/icon.png", title, url, sharecallback);
 }