Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can't disable Button interaction with Canvas Group (SOLVED)

Discussion in 'Scripting' started by Falisto, Feb 9, 2020.

  1. Falisto

    Falisto

    Joined:
    Feb 9, 2020
    Posts:
    2
    Hello, my name is Falisto!

    I am pretty new to Unity, but I got used to it, I love it!
    My issue is, that I have all UI elements like buttons, texts etc in one single canvas
    and whenever my "Game Over" texts appear, I would like to disable my buttons,
    which are for controlling the player.

    Whenever I untick "interactable" in "Button(Script)" inside of the inspector, the buttons
    appear grey, but I can still interact with them. Something you maybe want to know is that
    all UI elements have an individual canvas group to adjust ".alpha".
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,749
    I haven't fiddled much with CanvasGroups but they are speciflcally used to disable interaction:

    https://docs.unity3d.com/Packages/com.unity.ugui@1.0/manual/class-CanvasGroup.html

    See if maybe the reverse is true too: they might force otherwise non-interactive buttons to be interactive. Not sure... it would be easy for you to quickly test right in the Unity editor, just using a simple script and fresh scene with some sample UI.
     
  3. Falisto

    Falisto

    Joined:
    Feb 9, 2020
    Posts:
    2
    I have found the solution! I don't know whether it also has to do with it, but I was using the Event Trigger component to call movement functions.

    If you read this and use Canvas Groups, JUST DISABLE "BLOCKS RAYCASTS" ;)
     
    Biliogadafr, AndreSTN and Kurt-Dekker like this.
  4. WookieWookie

    WookieWookie

    Joined:
    Mar 10, 2014
    Posts:
    34
    No, no no. This is not a solution. This is a different feature.

    Interactable is related to Disabled on Selectables. There is a difference between disallowing raycasts and disallowing input. Often disallowing raycasts is used while in transition to another screen. But disallowing input needs to be communicated to the user by graying out the button, as per standard UX practices.

    Interactable on Canvas Group SHOULD be setting Interactable on any Selectable at same level or as a child. This is a bug. This issue is not solved.