Search Unity

Read .jpg files in android build not working

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

  1. Hunubul

    Hunubul

    Joined:
    Dec 17, 2018
    Posts:
    65
    Hey!
    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

    Hunubul

    Joined:
    Dec 17, 2018
    Posts:
    65
    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?