Sharath Kumar
Sharath Kumar

Reputation: 145

Unity 3D: Loading an image from device memory shows an image with Question mark

Am taking a snap and setting that image as background to other scene,but finally that background is showing a question marked image..enter image description here

FYI the image already exists, i have checked that with File.exists(). and here is the code snippet i have used.

IEnumerator DisplayTexture() {
        WWW www = new WWW(SelfiateUtils.SnapImagePath);
        yield return www;

        BGTexture.mainTexture = www.texture;
        //Trace.text="Assaigned successfully";
        if (www.error == null) {

        }    
    }
SelfiateUtils.snapImage is the string url where i have saves the file.

can any one help me to fix this. thanks.. :)

Upvotes: 0

Views: 2601

Answers (1)

EdPS
EdPS

Reputation: 331

Just to complement the answer in the comments and give it more visibility, as stated by Sharath, one must add "file://" as as prefix to load image files (jpg, jpg) in iOS.

This particularly important to remember when loading streaming assets. This prefix must be added before Application.streamingAssetsPath in iOS and also when running the app in the Unity Editor (Win and MacOS). In Android this prefix should be omitted.

Upvotes: 1

Related Questions