pengwang
pengwang

Reputation: 19946

How to load image from folder but not resource folder

I put my image at /Assets/Test/Textures/Player but without success my code is:

IEnumerator loadTexture(string videotype) {

    if(videotype.Equals("3d")) {

        WWW www = new WWW("file:///Assets/Meta1/Textures/Player/3D_foucs.png");
        yield return www;
        texture3D.mainTexture = www.texture;

    } else if(videotype.Equals("2d") ){

    } else if(videotype.Equals("360")) {

    }        
}

Upvotes: 0

Views: 4320

Answers (1)

Umair M
Umair M

Reputation: 10720

Place your png file in Resources folder of your project and load it using:

 Texture2D _texture = Resources.Load("3D_foucs.png") as Texture2D;

EDIT :

If you really want to avoid using Resources.Load() then you can use Application.dataPath to access assets folder. But make sure you read the docs before that.

P.S : WWW is usually good for loading stuff from outside of project.

E.g from Application's Persistent Data or from web server.

Hope it helps

Upvotes: 1

Related Questions