SetPixels - Unsupported Texture Format

Hi

I am using a colour picker to change the colour of a texture - part of a larger plan I have in mind - but I am getting
“Unsupported texture format - needs to be ARGB32, RGBA32, RGB24 or Alpha8” on Skin.SetPixels(SkinColors);

Skin is an imported texture that has been converted to ARGB32 in Unity and the var Col is ARGB so I am
not sure why I am getting this error.

Please help?

using UnityEngine;
using System;
using System.Collections;

public class ColorPicker : MonoBehaviour {
	
	public Texture2D Skin;
    public Texture2D colorPicker;
    public int ImageWidth = 100;
    public int ImageHeight = 100;
	private Color[] SkinColors;


    void OnGUI(){

        if (GUI.Button(new Rect(10, 10, ImageWidth, ImageHeight), colorPicker)) {

                Vector2 pickcol = Event.current.mousePosition;
                int xpos = Convert.ToInt32(pickcol.x);
                int ypos = Convert.ToInt32(pickcol.y);
                Color col = colorPicker.GetPixel(xpos,41-ypos);
				SkinColors = Skin.GetPixels();
			
			    for(int x = 0; x < SkinColors.Length; x++)
    			{
       				SkinColors[x] = col;
    			}
 				Skin.SetPixels(SkinColors);
				Skin.Apply();
			
        }

    }

}
1 Like

Have you got the Read Write Enabled option switched on the the texture import settings? (Set the texture type to Advanced to see this option.)

2 Likes

I’m kind of late, but I might be able to prevent people from asking the same question again,
As the error says, you need to change the format of the texture to one of the given formats:


By default “Automatic Compression” is selected.

53 Likes

I love this post. Magiichan saved me.

2 Likes

But what about the image size when we don’t compress it…

Are these options available in Unity 2017.3.0f3 ? I want to use ARGB 32 Bit but can’t seem to find it anywhere. Any help would be really appreciated

1 Like

Maybe?3659443--299533--upload_2018-9-10_14-42-37.png

3 Likes

Thank you, Magiichan, that saved me a lot of headache!

2 Likes

Thank you for saving me time. It works

1 Like

Still relevant 2020. Thank you!

1 Like

I love this post.

1 Like

worked for me

I have spent 3 days trying to get this to work and nowhere until now did anyone mention that the format is not set the same as what is loaded. Being new I didn’t appreciate the bottom part of the window (once again not mentioned anywhere by anyone else).

Thank you so much.

QUOTE=“Magiichan, post: 1667095, member: 519638”]I’m kind of late, but I might be able to prevent people from asking the same question again,
As the error says, you need to change the format of the texture to one of the given formats:


By default “Automatic Compression” is selected.[/QUOTE]

3 Likes

Perfect solution, thanks!

1 Like

Was struggling with this too, thanks!

1 Like

thanks

1 Like

Absolute legend. Thank you

1 Like

thanks

Please use the “Like” button to show appreciation so as not to necro threads.

Thanks.

1 Like

By the way, if you generate a texture with code, then use GraphicsFormat.R32G32B32A32_SFloat to be able SetPixels(…) method on it later. For example:

Texture2D myTex= new Texture2D(sizeX, sizeY, GraphicsFormat.R32G32B32A32_SFloat, TextureCreationFlags.None);
myTex.SetPixels(...); // Will be performed successfully.