New to the forums? Click here to read the "How To" Guide.

Developer? Click here to go to the Developer Forums.

Unity scripting, read .jpg files

HunubulHunubul Posts: 2

So I use Unity, C#. I never used java, and don't plan to, especially because Unity has a java class and java object for C# scripts. The problem is, I still struggle with writing a working code.

I actually have 2 questions: how do I read file from a specific folder outside my app directory? I just want to create my own folder on the Oculus Go, and be able to read it, but I don't have permission, even if I set write permissions for SD card. It just says access to the path denied. What code should I use to access it? What do I need to set in Unity? How exactly do I do that, because obviously I know nothing about this... I mean I got to setting player settings to let me write to SD card but that's it. I don't even know if I have to do something on the Oculus Go or not.

And the more important question: even if I use persistentDataPath, I can't read the bytes of the .jpg files. It simply doesn't happen. I try to use the same code for PC and android, for a few exceptions where I use #IF, but I would think that using the same method for loading a .jpg works. Looks like I was mistaken...

My code for reading the .jpg is simple:

WWW reader;
byte[] fileData;
Texture2D t;

reader = new WWW(path + "/" + filename);
t = new Texture2D(2, 2);
fileData = reader.bytes;

The path works, I make Oculus Go write it on a canvas, and it's what it's supposed to be. Then I get access denied when I try to even get a list of files.
And if I use persistentDataPath, I can read .txt just fine. But when I try to load .jpgs, and try to make them appear, nothing happens. Can anyone help me?

Also a third question, but it's related solely for Unity: there is a blue seam where the 360 image edges meet. How do I make it disappear? The image is fine, it works with other programs. And on the unity forums noone answers this question.


  • HunubulHunubul Posts: 2
    just to be clear, I try to use the .jpg like this:


    I use the panoramic render shader someone made to be able to watch 360 videos and such. I'm not sure if the problem is the way I use the loaded .jpg, or if it gets stuck on reading. I just have an educated guess that I can't read the bytes, but if I'm wrong please correct me.
Sign In or Register to comment.