Search Unity

Question if UI masked disable object / if UI not masked enable object

Discussion in 'Scripting' started by Proto-G, Mar 22, 2021.

  1. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    I'm using a Scroll Rect with a mask. I'm not sure how to enable each object that's not masked and disable each object that's masked.
    Example:
    if masked
    disable
    else if not masked
    enable
     
  2. TadasTalalas

    TadasTalalas

    Joined:
    Nov 7, 2016
    Posts:
    33
    collectionmenu.gif

    What you want to hide objects like this?
     
  3. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    The objects are already hidden by the mask. I want to disable the objects that are hidden by the mask and enable them when they come into view.
     
  4. TadasTalalas

    TadasTalalas

    Joined:
    Nov 7, 2016
    Posts:
    33
    This sounds like you want to do object pooling right? To optimise game and get rid of lag? If it's true then search "object pooling ui" something like that..
     
  5. Proto-G

    Proto-G

    Joined:
    Nov 22, 2014
    Posts:
    213
    I am using Object Pooling for the main UI Scroll Rect. But it uses a Mask to hide the items outside of the Viewport. I want to write a simple C# script that disables the items outside the Viewport from the hierarchy. Then once the items are inside the Viewport, I want to enable them.

    I need access to Mask.cs so I can write a script:
    (referencing Mask.cs)
    if masked (outside of Viewport)
    disable this item from heirarchy
    if not masked (inside Viewport)
    enable this item from heirarchy