DisplayAnswer(-1); causes button shape change

The line Display Answer causes the correct answer sprite button to double in height during the answering question phase of the game. The sprite itself doesn’t change. So I’m confused why the change in height when none of the code is meant to change the sprite’s size?

Edit: Now that I added more questions following the video on Lists, It seems that the only button effected is the third one regardless if it is the correct answer or not.

Hi Tomas,

That sounds odd. Does one of the buttons have no text? If so, that could at least explain the behaviour because the layout group automatically expands the buttons.

Try to give all button game objects (= the children of the layout group) a LayoutElement component. Set the Preferred Size to 80 or whatever makes sense in the context of your game.

You’ll probably have to adjust the settings in the LayoutGroup, so the it uses the preferred size defined in the LayoutElements.

Did this help you fix the problem?


See also:

Hello Nina,

Thanks for the reply. I continued with the lessons and the button issue resolved itself automatically. I don’t know why and I haven’t been able to recreate it. The only thing I can think of is maybe it was a weird bug with my version of Unity.

That’s not uncommon. Restarting often magically fixes certain issues. :slight_smile:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms