Search Unity

(Answered) Image to Sprite [2019.2.3]

Discussion in 'Scripting' started by Deleted User, Nov 6, 2019.

  1. Deleted User

    Deleted User

    Guest

    I am downloading an image as Texture during runtime and want to display it in my UI.
    How do I convert Texture to Sprite for UI during runtime?

    I only found how to convert Texture2D to Sprite. But not Texture to Texture2D.
     
  2. Chris-Trueman

    Chris-Trueman

    Joined:
    Oct 10, 2014
    Posts:
    1,261
    Simply cast the Texture to Texture2D.

    Code (CSharp):
    1. Texture2D image = www.texture as Texture2D;
    2.  
     
    Deleted User likes this.
  3. Deleted User

    Deleted User

    Guest

    It worked! Thank you. It really was that easy. :D