• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Tohron · May 25, 2019 at 02:16 AM · texture2dfilewebrequest

UnityWebRequestTexture Unable to Load From Directories Containing '#' or '+' Characters

I'm using UnityWebRequestTexture to load images from my file system into my game. Here is my code:

 private IEnumerator ImageLoadCoroutine(int i)
     {
             GameObject imgObj;
             Texture2D imageTex = null;
             //string activeDir = fileList[i];
             //activeDir = activeDir.Replace("+", "+"); // Does not fix issue!
             //using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(activeDir))
             using (UnityWebRequest uwr = UnityWebRequestTexture.GetTexture(fileList[i]))
             {
                 yield return uwr.SendWebRequest();
 
                 if (uwr.isNetworkError || uwr.isHttpError)
                 {
                     //  "+" dirs have HttpError
                     Debug.Log(uwr.error + "(" + uwr.isNetworkError + ", " + uwr.isHttpError + ")");
                 }
                 else
                 {
                     // Get downloaded asset bundle
                     imageTex = DownloadHandlerTexture.GetContent(uwr);
                 }
             }
             imgObj = Instantiate(imagePrefab);
             imgObj.transform.SetParent(imageContainer.transform);
             imgObj.transform.localPosition = Vector3.zero;
             imgObj.transform.localRotation = Quaternion.identity;
             imgObj.transform.localScale = Vector3.one;
             imgObj.GetComponent<RawImage>().texture = imageTex;
             imgObj.GetComponent<RawImage>().enabled = false;
             imgObj.GetComponent<BoxCollider>().enabled = false;
         imagesLoaded++;
         imageList[i] = imgObj;
 
     }

However, when I try to load images from directories containing the '+' or '#' characters (i.e. "C:\Users\MyUser\Documents\Unity Projects\The+++Folder"), I get the HttpError: "HTTP/1.1 404 Not Found" Directories containing other special characters like @, &, or = work fine. Using the Replace function to replace the characters with their character entity reference code (i.e., replacing all instances of "+" with "& plus ;") did not fix the problem.

What is the source of this issue, and is there a way around it? I'd rather not be arbitrarily restricted in which valid folder names actually work with my program.

Thanks!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

111 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

$_FILES is empty when I send a file from WWWForm 2 Answers

Texture2D.GetPixels().Length is smaller on iOS build than in Editor 0 Answers

How do I get file size of texture? 1 Answer

Saving texture of selected GO (Editor Script) 2 Answers

Not enough data provided while loading bytes downloaded from url picture to Texture2D 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges