Change color of button and convert string into int
Hi, I am trying to change the colors of the buttons when a statement is true.
void Start()
{
if ((int.Parse(gameObject.name)) >= GameController.Instance.CurrentLevel + 1)
{
gameObject.GetComponent<Image>().color = new Color(96, 96, 96, 255);
}
}
i thought it was like this but the colors won't change when loaded. Does anyone see the problem?
Comment
Answer by Dizy · May 14, 2020 at 03:45 PM
Parsing string into int is not the best way, use the debug mode of your IDE to check if the if is triggered, if not then Debug.Log your (int.Parse(gameObject.name)) to see if you get the expected value.