Reputation: 3
I am recently started working with Unity3D, I am working with Unity3D version 5.3.0;
I have sprite object in my application, currently I am importing image and converting its texture type from texture to sprite. and the manually liking it with sprite renderer of my sprite object.
I want to change sprite (2D texture) in sprite renderer at the runtime. and the texture file (png image) is stored on my server.
using www class I can download it in a texture file but the question is, How i can convert the texture type from texture to sprite before assigning it to sprite?
Upvotes: 0
Views: 585
Reputation: 4112
When you say that you can download the texture, do you manage to get a unity object (such as a Texture2D), or just the image file downloaded on your computer?
If you managed to get a unity texture object, you can have a look at the Sprite.Create function
If you just get the file, I think this isn't enough to convert it to a correct Unity object. You should prepare an Unity asset bundle containing your sprite (have a look on google, there is plenty of info about asset bundles) and store the asset bundle on your server. This way you can download usable unity objects (for instance, a Sprite)
Upvotes: 1