- Home /
Question by
rhylvin2017 · Dec 06, 2018 at 05:10 AM ·
wwwwindows store appwww.texture
Hololens url to texture is not working
URL to Texture is working if using Unity Editor but when I build for Hololens I get this error.
ArgumentNullException: Value cannot be null.
Parameter name: _unity_self
at UnityEngineProxy.InternalCalls.UnityWebRequest_Get_Custom_PropIsDone(Object self)
at UnityEngine.WWW.WaitUntilDoneIfPossible()
at UnityEngine.WWW.CreateTextureFromDownloadedData(Boolean markNonReadable)
at ShelfMarkingPage.<>c__DisplayClass7_0.<startLoadImage>b__0()
at UnityThread.Update()
at UnityThread.$Invoke10(Int64 instance, Int64* args)
at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method)
Here is my script:
private IEnumerator startLoadImage()
{
#if !UNITY_EDITOR
Debug.Log("Image: " + ShelfHandle.ShelfHandler.Instance.ShelfImageURL);
using (WWW www = new WWW(ShelfHandle.ShelfHandler.Instance.ShelfImageURL))
{
yield return www;
try
{
UnityThread.executeInUpdate(() =>
{
Debug.Log("startLoadImage");
// assign texture
Sprite spr = new Sprite();
Debug.Log("startLoadImage");
spr = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0), 100.0f);
Debug.Log("startLoadImage");
ShelfImage.GetComponent<Image>().sprite = spr;
Debug.Log("startLoadImage");
ShelfImage.SetActive(true);
Debug.Log("startLoadImage");
});
}
catch (Exception e)
{
Debug.Log(e.Message);
}
}
#else //test Shelf_ImageURL
using (WWW www = new WWW("http://storage.rev-kitten.com/storage/static/uploads/pharmacy/4dc2a52e97040576d0e92d7ca20b6ae8.jpg"))
{
yield return www;
try
{
Debug.Log("startLoadImage");
// assign texture
Sprite spr = new Sprite();
Debug.Log("startLoadImage");
spr = Sprite.Create(www.texture, new Rect(0, 0, www.texture.width, www.texture.height), new Vector2(0, 0), 100.0f);
Debug.Log("startLoadImage");
ShelfImage.GetComponent<Image>().sprite = spr;
Debug.Log("startLoadImage");
ShelfImage.SetActive(true);
Debug.Log("startLoadImage");
}
catch (Exception e)
{
Debug.Log(e.Message);
}
}
#endif
}
The error is in the Sprite.Create i think this means that the www is null. but why? it returned the www so it should have value already? I also tried using
using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(ShelfHandle.ShelfHandler.Instance.ShelfImageURL))
same result. the uwr in this instance has been returned but with no value.
P.S. InternetClient, InternetClientServer is also turned on even though it is not needed for the editor.
Comment
Try printing out isDone property of your WWW request.. "UnityEngine.WWW.WaitUntilDoneIfPossible()" I think its not waiting for download to complete..