예제 #1
0
    void OnGUI()
    {
        GUI.skin = demoSkin;

        float scale = 1.0f;

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            scale = Screen.width / 320;
        }

        float btnWidth  = 200 * scale;
        float btnHeight = 45 * scale;
        float btnTop    = 20 * scale;

        GUI.skin.button.fontSize = Convert.ToInt32(16 * scale);

        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Authorize"))
        {
            AuthResultEvent evt = new AuthResultEvent(AuthResultHandler);
            ShareSDK.authorize(PlatformType.SinaWeibo, evt);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get User Info"))
        {
            GetUserInfoResultEvent evt = new GetUserInfoResultEvent(GetUserInfoResultHandler);
            ShareSDK.getUserInfo(PlatformType.SinaWeibo, evt);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share Menu"))
        {
            Hashtable content = new Hashtable();
            content["content"]     = "this is a test string.";
            content["image"]       = "http://img.baidu.com/img/image/zhenrenmeinv0207.jpg";
            content["title"]       = "test title";
            content["description"] = "test description";
            content["url"]         = "http://sharesdk.cn";
            content["type"]        = Convert.ToString((int)ContentType.News);
            content["siteUrl"]     = "http://sharesdk.cn";
            content["site"]        = "ShareSDK";
            content["musicUrl"]    = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3";

            ShareResultEvent evt = new ShareResultEvent(ShareResultHandler);
            ShareSDK.showShareMenu(null, content, 100, 100, MenuArrowDirection.Up, evt);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Show Share View"))
        {
            Hashtable content = new Hashtable();
            content["content"]     = "this is a test string.";
            content["image"]       = "http://img.baidu.com/img/image/zhenrenmeinv0207.jpg";
            content["title"]       = "test title";
            content["description"] = "test description";
            content["url"]         = "http://sharesdk.cn";
            content["type"]        = Convert.ToString((int)ContentType.News);
            content["siteUrl"]     = "http://sharesdk.cn";
            content["site"]        = "ShareSDK";
            content["musicUrl"]    = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3";

            ShareSDK.customSinaWeiboShareContent(content, "sina weibo test string", InheritedValue.VALUE, null);

            ShareResultEvent evt = new ShareResultEvent(ShareResultHandler);
            ShareSDK.showShareView(PlatformType.Any, content, evt);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Share Content"))
        {
            Hashtable content = new Hashtable();
            content["content"]     = "this is a test string.";
            content["image"]       = "http://img.baidu.com/img/image/zhenrenmeinv0207.jpg";
            content["title"]       = "test title";
            content["description"] = "test description";
            content["url"]         = "http://sharesdk.cn";
            content["type"]        = Convert.ToString((int)ContentType.News);
            content["siteUrl"]     = "http://sharesdk.cn";
            content["site"]        = "ShareSDK";
            content["musicUrl"]    = "http://mp3.mwap8.com/destdir/Music/2009/20090601/ZuiXuanMinZuFeng20090601119.mp3";

            ShareResultEvent evt = new ShareResultEvent(ShareResultHandler);
            ShareSDK.shareContent(PlatformType.SinaWeibo, content, evt);
        }


        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Friends SinaWeibo "))
        {
            GetFriendsResultEvent evt = new GetFriendsResultEvent(GetFriendsResultHandler);
            ShareSDK.getFriends(PlatformType.SinaWeibo, null, evt);
        }

        btnTop += btnHeight + 20 * scale;
        if (GUI.Button(new Rect((Screen.width - btnWidth) / 2, btnTop, btnWidth, btnHeight), "Get Token SinaWeibo "))
        {
            GetCredentialResultEvent evt = new GetCredentialResultEvent(GetTokenResultHandler);
            ShareSDK.getCredential(PlatformType.SinaWeibo, evt);
        }
    }