I am trying to change color of a text component when its parent panel has been clicked. After watching this tutorial (especially the part at 3:45) I understand that it is not possible to pass Color parameter via event function call. I was able to work around it creating this simple script:
public class TextColorHandler : MonoBehaviour {
public Color[] colorArray;
public void SetColor(int colorArrayIndex) {
GetComponent<Text> ().color = colorArray [colorArrayIndex];
}
}
I put the script as a sibling component next to the Text component. I feed the array with desired colors in editor and then reference to them with corresponding array index in event function call (since integer type is OK as a event parameter).
Now my question is, what other ways are in Unity do the same thing ? Preferably more elegant/intuitive, or without use of custom scripts. I feel like it’s quite over the top to do such simple thing by script. The only other way I can think of are materials, but then again - having the same material stored multiple times that only differ in color …