在Unity中 微信分享功能已经做出来了 即知道了图片在手机SD卡中所在位置
但是用www读取会报错 检查代码并没有写错
原因是手机截图后放进sd卡有一定的时间 在期间如果www读取图片的话就会报错
我的解决方法是将时间延迟1秒读取(看手机性能如何)
测试机华为P9 要1s才能读取
如果有一个函数是等可以读取了再读取 请告诉我
代码如下:
void Start()
{
StartCoroutine("ShowImageButton");
}
public IEnumerator ShowImageButton()
{
yield return new WaitForSeconds(1f);
WWW www = new WWW("file://" + Application.persistentDataPath + "/1.png");
image.GetComponent<Image>().sprite = Sprite.Create(www.texture, new Rect(0, 0, Screen.width, Screen.height), new Vector2(0.5f, 0.5f));
}