How to change the color of an image with script?

I want to change the color of a image in my scene with a script and it gives me this error. I’m using Unity5. How can I fix this?

image.color = new Color32(255,255,255,100);

error CS1061: Type UnityEngine.GameObject' does not contain a definition for color’ and no extension method color' of type UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?)

Your “image” variable is of type GameObject and the GameObject class doesn’t have a color property or member (that’s what the error message is telling you), it must be an Image variable. Try this:

image.GetComponent<Image>().color = new Color32(255,255,225,100);

I understand from error that you declare “image” as a GameObject. You need to declare it as an Image.

Follow the link below for more information about Image class: