TransWikia.com

Button not clickable if it's under a Content Size Fitter + Horizontal Layout Group in Unity?

Game Development Asked on November 20, 2021

I’d like to make a Tooltip System/Tutorial System.

I’m using the Content Size Fitter and Horizontal Layout Group components to have a dynamic text bubble..

Also I’d like to attach a button to it,

  • so when the tooltip appears, the game pauses,

  • and then when the player clicks the button, it closes the tutorial text, resuming the flow of the game.

But for some reason the click doesn’t reach the component. Not even the animation happen, like something is blocking my button from being clicked.

Hierarchy:

enter image description here

uiTutorialText

  • Has a CanvasGroup to fade the whole structure.

    • Interactable = true, BlocksRaycast = false

TutorialText

  • Has an Image (background)

    • RaycastTarget = false
  • Has a Content Size Fitter and a Horizontal Layout Group
    enter image description here

And Text and Button are just simple plain Text and Button objects, and the Button’s Interactable is true.

I also tried making the Button a child of Text, and then translating it sideways, so the button doesn’t share screen space with the tooltip. But it’s not clickable this way as well.

As soon as I move the Button out of the hierarchy, like directly under the canvas, it works.

One Answer

Has a CanvasGroup to fade the whole structure. Interactable = true, BlocksRaycast = false

Try checking "blocks raycast". CanvasGroup applies to the parent and all of its children. Unchecking "blocks raycast" is telling Unity "this object and all of its children should ignore the mouse".

Answered by Kevin on November 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP