Color in event handler

I cannot figure this out

I have a function

public void ChangeCubeColor(Color c)
{
//Color c = Color.red;
cube.GetComponent ().material.color = c;
//uiText.text = c;
}

Except the function won’t show up in the on click event handler for a button… not sure why. If I change it from Color c to string c, it does show up, but then I can’t use the color.

Can colors not be passed from the On Click() event handler in a button?

it can only be a float, int, string, bool, or unityObject (gameobject, trasnform, etc), but color is not one of these

suspected so but that’s alright :slight_smile: thanks for reply

make it a string, then convert your color codes to a hex format :wink:

1 Like