Test.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using cn.sharesdk.unity3d;
  6. using UnityEngine.UI;
  7. public class Test : MonoBehaviour
  8. {
  9. public Text Text;
  10. public Texture2D Texture2D;
  11. private string FilePath;
  12. public void Awake()
  13. {
  14. ShowListHttp.Test();
  15. //FilePath = $"{Application.persistentDataPath}/Test.png";
  16. //if (!File.Exists(FilePath))
  17. //{
  18. // File.WriteAllBytes(FilePath, Texture2D.EncodeToPNG());
  19. //}
  20. //Text.text = FilePath;
  21. //ShareSDK = gameObject.AddComponent<ShareSDK>();
  22. //ShareSDK.Initialize();
  23. //ShareSDK.shareHandler = ShareCallback;
  24. }
  25. public static ShareSDK ShareSDK;
  26. public void TestShare()
  27. {
  28. ShareContent shareContent = new ShareContent();
  29. shareContent.SetText("content");
  30. shareContent.SetTitle("title");
  31. shareContent.SetTitleUrl("www.baidu.com");
  32. shareContent.SetSite("www.baidu.com");
  33. shareContent.SetSiteUrl("www.baidu.com");
  34. shareContent.SetUrl("www.baidu.com");
  35. shareContent.SetShareType(ContentType.App);
  36. //shareContent.SetImageUrl("http://or5zgoeui.bkt.clouddn.com/game_icon.png");
  37. shareContent.SetImagePath(FilePath);
  38. ShareSDK.ShowPlatformList(null, shareContent, 100, 100);
  39. Text.text = "¿ªÊ¼·ÖÏí";
  40. }
  41. public void ShareCallback(int reqID, ResponseState state, PlatformType type, Hashtable result)
  42. {
  43. if (state == ResponseState.Success)
  44. {
  45. Text.text = "Success";
  46. }
  47. else if (state == ResponseState.Fail)
  48. {
  49. Text.text = "Fail";
  50. }
  51. else if (state == ResponseState.Cancel)
  52. {
  53. Text.text = "Cancel";
  54. }
  55. }
  56. }