How to convert System.IO.Stream into a Texture in Unity for Android?

后端 未结 1 674
闹比i
闹比i 2021-01-23 16:13

I\'m building a client-side Android app in Unity, and when it downloads a jpg from an AWS S3 server, the result comes back as a System.IO.Stream.

However my limited know

1条回答
  •  臣服心动
    2021-01-23 16:31

    You are looking for the LoadImage function from the Texture2D class. This function converts PNG/JPG image byte array into a texture.

    Texture2D tex = new Texture2D(2, 2);
    tex.LoadImage(stream);
    

    The stream variable must be byte array(byte[]) from the internet / AWS S3 serve.

    0 讨论(0)
提交回复
热议问题