Tip - Buttons - add the sprite as a child of the button object for easier placement

When adding the buttons to the button bar, if like me you need things to line up correctly, and have a nightmare with the scale and position of the sprites whilst maintaining the Hitbox2D position and scale, then simply add a child object of the button, and have the sprite on there.

Basically the same technique shown when creating in actual Attackers/Defenders, not only does it make the buttons easier to place, but also means if you choose, you can add other aspects to the ‘Button Object’ such as background panels etc.

I did that too - I had a devil of a time lining up the buttons - but with part 1 of the challenge I couldn’t figure out how to black out the buttons, I couldn’t access the Sprite Renderer component on the child object, even using a public variable and setting it to the child object, I know it can be done, but, I can’t find it at the moment :face_with_raised_eyebrow:.

Unless im missing something there is an issue with this in that the script needs to be on the same gameobject as the sprite render to turn them black or white. Also to acknowledge the mouse click the collider also has to then be on the child, so you are right back to square one.

Unless anybody has a recommendation of how to set this up?

Privacy & Terms