1.分享链接时最后只显示分享了图片原因是下图中如勾选了BypassApproval,则在分享时会绕过微信验证,但是功能不全,只能一图片方式分享图片,所有取消勾线就好了
2.分享本地图片是路径权限问题
ios图片放在 StreamingAssets只读文件夹下面,写入下面的代码。
content["image"] = Application.streamingAssetsPath+”/pic.png”;
安卓得放在sdcard中才可以,需要在分享前把u3d里的图片拷贝到sdcard卡里面,这也是我看有其他前辈这么摸索出来的。在Resources文件夹下放一个图片,记住一定要PNG,在U3D里面把图片的格式修改成RGBA。
//读、写的路径
string imagePath = Application.persistentDataPath + "/pic.png";
//如果文件不存在,把它拷贝进去。
if(!System.IO.File.Exists(imagePath))
{
Texture2D o = Resources.Load("pic ") as Texture2D;
System.IO.File.WriteAllBytes(imagePath, o.EncodeToPNG());
}
这样在分享图片的时候路径就可以直接写了
string imagePath = Application.persistentDataPath + "/ pic.png";
if(System.IO.File.Exists(imagePath))
{
content["image"] = imagePath;
}
如果你想分享的是一张截屏图片,这样来写
Application.CaptureScreenshot("screen.png");
content["image"] = Application.persistentDataPath + "/screen.png";