Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Read .jpg files in android build not working

Discussion in 'Scripting' started by Hunubul, Jan 11, 2019.

  1. Hunubul


    Dec 17, 2018
    I have a code right here, that should IMO work, and it works on PC. I also want it to work on Android, but it just gives a grey screen, meaning the textures didn't load.

    Code (CSharp):
    1. private string filepaths;
    2. private Texture2D images;
    3. void Start()
    4. {
    5.         kepnevek = Directory.GetFiles(Application.streamingAssetsPath + "/images", "*.jpg");
    6. }
    7. private void AsdfAsdf()
    8.     {
    9.         images = new Texture2D[filepaths.Length];
    10.         Texture2D tex;
    11.         byte[] fileData;
    12.         WWW reader;
    13.         for (int i = 0; i< filepaths.Length; i++)
    14.         {
    15.             reader = new WWW(filepaths[i]);
    16.             while (!reader.isDone) { }
    17.             tex = new Texture2D(2, 2);
    18.             fileData = reader.bytes;
    19.             tex.LoadImage(fileData);
    20.             images[i] = tex;
    21.         }
    22.     }
    I set the first image at the start, so I should immediately see if it works. On PC it worked without the while, on android it doesn't seem to work at all.

    Thanks in advance!
  2. Hunubul


    Dec 17, 2018
    I can also use a set directory in Oculus Go, but I don't know what would the access patch be, and I can't find it. Can someone help me with that?