Hi all,
Ben didn’t really give me much to go on with this challenge, not tips on anything really SO I am having trouble and don’t know really what I should be doing. I managed to get the first part of the challenge done by accessing the Sprite Renderer component with this:
void Start () {
//black out all buttons
myColour = new Color(0,0,0,1);
sr = GetComponent<SpriteRenderer>();
sr.color = myColour;
}
That worked, all the buttons are blacked out.
And getting the Button that is clicked upon showing correct colour was done in a similar way:
//catch the OnMouseDown Condition
public void OnMouseDown()
{
//get the object
GameObject btnSelected = this.gameObject;
//make button pressed go to correct colour
print(name+ ": pressed");
Color btnColour = new Color(1, 1, 1, 1);
btnSelected.GetComponent<SpriteRenderer>().color = btnColour;
}//end OnMouseDown
But I cannot figure out how I might go about resetting all the buttons before this so when I choose another buttons they “all” go black to black to start with and then set the one I want with the original colour! The only thing I keep going back to is an array, but, I am am not really up to speed with using arrays in Unity and cycling through the array. So I am really lost. Would someone be able to point me in a direction to take? Hitting my head against the brick wall is starting to hurt .
As always any help is appreciated.
Regards,
Vaughan.