Share.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using cn.sharesdk.unity3d;
  5. public class Share : MonoBehaviour
  6. {
  7. #region 变量
  8. public ShareSDK ShareSdk;
  9. #endregion
  10. private void Awake()
  11. {
  12. ShareSdk.shareHandler = ShareCallback;
  13. ShareSdk.showUserHandler = AuthorizeCallback;
  14. }
  15. private void FixedUpdate()
  16. {
  17. }
  18. public void ShareTest()
  19. {
  20. ShareContent shareContent = new ShareContent();
  21. shareContent.SetText("SetText");
  22. shareContent.SetTitle("SetTitle");
  23. shareContent.SetSite("SetSite");
  24. shareContent.SetComment("SetComment");
  25. shareContent.SetShareType(ContentType.App);
  26. ShareSdk.ShowPlatformList(null, shareContent, 100, 100);
  27. }
  28. public void AuthorizeTest()
  29. {
  30. ShareSdk.Authorize(PlatformType.QQ);
  31. }
  32. public void ShareCallback(int reqID, ResponseState state, PlatformType type, Hashtable result)
  33. {
  34. if (state == ResponseState.Success)
  35. {
  36. print("Success");
  37. }
  38. else if (state == ResponseState.Fail)
  39. {
  40. print("Fail");
  41. }
  42. else if (state == ResponseState.Cancel)
  43. {
  44. print("Cancel");
  45. }
  46. }
  47. public void AuthorizeCallback(int reqID, ResponseState state, PlatformType type, Hashtable result)
  48. {
  49. if (state == ResponseState.Success)
  50. {
  51. print("Success");
  52. }
  53. else if (state == ResponseState.Fail)
  54. {
  55. print("Fail");
  56. }
  57. else if (state == ResponseState.Cancel)
  58. {
  59. print("Cancel");
  60. }
  61. }
  62. }