12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.IO;
- using cn.sharesdk.unity3d;
- using UnityEngine.UI;
- public class Test : MonoBehaviour
- {
- public Text Text;
- public Texture2D Texture2D;
- private string FilePath;
- public void Awake()
- {
- FilePath = $"{Application.persistentDataPath}/Test.png";
- if (!File.Exists(FilePath))
- {
- File.WriteAllBytes(FilePath, Texture2D.EncodeToPNG());
- }
- Text.text = FilePath;
- ShareSDK = gameObject.AddComponent<ShareSDK>();
- ShareSDK.Initialize();
- ShareSDK.shareHandler = ShareCallback;
- }
- public static ShareSDK ShareSDK;
- public void TestShare()
- {
- ShareContent shareContent = new ShareContent();
- shareContent.SetText("content");
- shareContent.SetTitle("title");
- shareContent.SetTitleUrl("www.baidu.com");
- shareContent.SetSite("www.baidu.com");
- shareContent.SetSiteUrl("www.baidu.com");
- shareContent.SetUrl("www.baidu.com");
- shareContent.SetShareType(ContentType.App);
- //shareContent.SetImageUrl("http://or5zgoeui.bkt.clouddn.com/game_icon.png");
- shareContent.SetImagePath(FilePath);
- ShareSDK.ShowPlatformList(null, shareContent, 100, 100);
- Text.text = "¿ªÊ¼·ÖÏí";
- }
- public void ShareCallback(int reqID, ResponseState state, PlatformType type, Hashtable result)
- {
- if (state == ResponseState.Success)
- {
- Text.text = "Success";
- }
- else if (state == ResponseState.Fail)
- {
- Text.text = "Fail";
- }
- else if (state == ResponseState.Cancel)
- {
- Text.text = "Cancel";
- }
- }
- }
|