Resize texture from prefab?

Hello community,

I am trying to obtain icons from prefabs by using AssetPreview.GetAssetPreview. It works, but the default size for the newly generated images is 128x128.

 rawIcon = AssetPreview.GetAssetPreview(target);
            icon = rawIcon as Texture2D;
            byte[] bytes = icon.EncodeToPNG();

Is there away to get larger images? I tried resizing the resulting texture after using AssetPreview.GetAssetPreview, but the pictures are blank:


Thank you

As you can read in the Resize documentation it does not resize the content. It just dumps the current conent and essentially creates a new internal texture with the new size.

You can use my TextureTools which provide two different methods to resample a texture. If the target aspect ratio is different from the source aspect ratio, depending on which method you use you either get a cropped texture or a letterboxed texture. When the aspect ration is the same it just resamples the image using bilinear filtering. I’ve written those TextureTools in response to this question.