Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Check if object is modified by CanvasGroup

Discussion in 'UGUI & TextMesh Pro' started by Antistone, Sep 13, 2019.

  1. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    Since this got no responses in the scripting forum, I guess I'll try again here in the UI forum...

    Is there a good way to determine (in script) whether a given object is transparent and/or interactable and/or blocks raycasts, taking into account any Canvas Groups in its ancestry that might be modifying these settings?

    I could obviously climb up the object hierarchy all the way to the root while checking for Canvas Group components at every step and manually calculate the compound of all of their effects, but I imagine Unity is already calculating that somehow for its own purposes, so I'd like to avoid the duplicated effort if possible.

    (The end goal is to have a MonoBehaviour that responds to keyboard input in its Update function, but that automatically stops responding if it's been hidden/disabled by an upstream Canvas Group.)