UnauthorizedAccessException iOS Loading an Image/Texture From Streaming Assets
My method works in the editor but not on device even though it acknowledges that the path exists. I've seen a few answers but nothing seems to be working. The error that I am getting:
Autoconnected Player UnauthorizedAccessException: Access to the path "/private/var/containers/Bundle/Application/58889FEE-16CC-4ABA-9FCE-B4D2AE2AF89C/virtualmeeting.app/Data/Raw/Items/Refinery/mdl_oilRefinery.obj" is denied. at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in :0
Code Snippet Below:
{
UnityWebRequest www = UnityWebRequest.Get(s.texturePath);
DownloadHandlerTexture handler = new DownloadHandlerTexture();
www.downloadHandler = handler;
yield return www.SendWebRequest();
if (www.isHttpError)
{
Inhance.Debug.Error(www.error);
}
else
{
float timeoutTime = Time.time + 3;
while (!handler.isDone || Time.time < timeoutTime)
{
yield return null;
}
if (handler.isDone)
{
s.texture = handler.texture;
if (go)
{
try
{
go.GetComponent<MeshRenderer>().material.mainTexture = s.texture;
}
catch
{
go.GetComponentInChildren<MeshRenderer>().material.mainTexture = s.texture;
}
}
}
}
}
Answer by UmaroXP · Jan 15, 2021 at 10:28 PM
Hey buddy did you ever find a solution to this? I have the exact same problem.
it was so long ago. I don't remember. It probably had something to do with the file permissions or the path. there has to be a file:// in front of the path. I do remember that. Sorry, I hope it helps.