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.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"; } } }