Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Texture2d LoadImage not preserving width and hieght

Discussion in 'Scripting' started by scossgrove, Jun 25, 2020.

  1. scossgrove

    scossgrove

    Joined:
    Jan 6, 2016
    Posts:
    35
    Hi All,

    I am making all my images in Photoshop and am exporting the image as PNGs using the "save as" functionality in Photoshop. All the source images are set up as RGB color mode with 8 bit chanels.

    I have a series of 128x128 and 256x512 images that work great when using the Texture2d.LoadImage function. They are loading the image and preserving the size and stating the format mode is ARGB32.

    However I have a series of images that are 2048x2048 that are not working however. The width and height are being reported as 8x8 and the format mode is RGB24.

    my code does the following:

    var fileData = File.ReadAllBytes(filePath);
    var tex = new Texture2D(2, 2);
    tex.LoadImage(fileData);

    Can anyone help me here?
     
  2. raarc

    raarc

    Joined:
    Jun 15, 2020
    Posts:
    535
    try it with a 1024x1024 image, if it works then try it with a 1025x1025 image

    It may just be that 2048 is too large for that function