Search Unity

Question Easiest way to completely disable a canvas

Discussion in 'UGUI & TextMesh Pro' started by Gordon_G, Jan 15, 2021.

  1. Gordon_G

    Gordon_G

    Joined:
    Jun 4, 2013
    Posts:
    372
    After dealing with Canvases, various UI elements, and sub-canvases and reading and rereading (and rereading!) all the documentation, and watching dozens of videos, and working with Canvases in detail for several years now, I think I understand a lot about canvases and UI elements but I still don't have a clear understanding of how interaction trickles down to child canvases and UI elements that have Raycast Target set to true.

    Any insight or help on these concepts is greatly appreciated!

    For example, say I have a Canvas set up like this:

    Code (text):
    1. Root Canvas Game Object 1:
    2.    Canvas component = enabled
    3.    GraphicRaycaster component = enabled
    4.    CanvasGroup component - Blocks Raycasts = true;
    5.   With child game objects:
    6.       >  game object 1 with UI Image component - Raycast Target = true
    7.       >  Child Canvas Game Object 2
    8.           Canvas component = enabled
    9.           GraphicRaycaster component = enabled  
    10.          With child game objects:
    11.             >  game object 2 with UI Image component - Raycast Target = true
    1. I understand that if I disable the Canvas component of the root game object, rendering is disabled for it and all child its game objects, and this is the most CPU efficient way to remove a canvas and all it's children from all rendering. Is this true? Does a CanvasGroup component have bearing on this practice?

    To the questions about disabling interactivity, because everything I have read states that #1 does not stop raycasts from being calculated on a canvas. Back to my example canvas:

    2. If I disable the Graphic Raycaster on the root, does that disable all interactivity on all children and all raycast calculations?

    3. From what I have read, #2 does not work, and that is what the GroupCanvas component was created to do. Setting Blocks Raycasts = false on the GroupCanvas will indeed disable all raycasting calculations on the canvas that contains that component and all of its child objects. Is this information accurate?

    4. And lastly, what does "blocking" mean? Because "Blocks Raycasts = true" certainly doesn't seem to block anything in the sense that "Block" means to prevent or stop - that I can understand. Maybe my mind is twisted or something, but if that is the way to disable raycast calucations, the logic seems backward.

    And on the GraphicRaycaster component there is the a "Blocking Objects" popup that doesn't seem to do anything I can make sense of when a canvas is on top of everything else.

    Can anyone give me a view of what this term is supposed to mean that jibes with my understanding of what to "block" means?

    Thanks!
     
    vozcn and McPeppergames like this.