Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Converting an NDArray to Texture2D?

Discussion in 'General Discussion' started by bw92, Jan 23, 2020.

  1. bw92

    bw92

    Joined:
    Apr 17, 2019
    Posts:
    20
    Hey all,

    I've searched online about converting a 2D Array (specifically NDArray) to a Texture2D but haven't found anything on this.

    Is this possible? I have a project that involves taking an output of a function which is an NDArray (2D array - Image) and then displaying it on a canvas which requires it to be a texture.

    Thanks.
     
  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    9,806
    I mean, you could convert it to one by taking the data from the array to create a new blank texture2d and then use setpixels but... that's going to be pretty slow when you could just use a mesh and set its vertex colours instead. Even that's not terribly efficient, but it'd certainly be faster.
     
    bw92 likes this.
  3. bw92

    bw92

    Joined:
    Apr 17, 2019
    Posts:
    20
    I didn't even think of that, tyvm!