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
  3. Dismiss Notice

Need to understand GetRawTextureData but I can't

Discussion in 'General Graphics' started by scossgrove, Jul 5, 2022.

  1. scossgrove

    scossgrove

    Joined:
    Jan 6, 2016
    Posts:
    23
    Hi,

    I have a texture that is 2048x2048 but when I call GetRawTextureData<Color32> I get an array of length 524,288.

    So what I cannot understand is why as 2048*2048 = 4,194,304 and how do I change the array element corresponding to say [10,10].

    Can anyone help?
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,533
    So you know, the 2D forum here is not related to general graphics questions.

    I'll move your post to the graphics forum for you.
     
  3. joshuacwilde

    joshuacwilde

    Joined:
    Feb 4, 2018
    Posts:
    692
    Probably you are calling it on a texture that is compressed. GetRawTextureData will return the compressed texture data. You need to use a uncompressed texture format to set the colors at runtime, or use a texture that unity supports runtime texture compression for.
     
  4. scossgrove

    scossgrove

    Joined:
    Jan 6, 2016
    Posts:
    23
    @joshuauacwilde I believe you are correct as the editor is show 2048x2048 RGB Compressed DXT1|BC1 UNorm when previewing the png.
     
    joshuacwilde likes this.