Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Culled MaskableGraphic stops being culled OnDisable

Discussion in 'UGUI & TextMesh Pro' started by GreenTVlad, Apr 29, 2021.

  1. GreenTVlad


    Oct 2, 2019
    Unity ver. 2019.4.4f1

    I'm using Image.onCullStateChanged event to determine if user have seen the content. This kind of images are nested inside scroll view. But unfortunately when I close window containing images, they are stop being culled by engine code in OnDisable method which calls UpdateClipParent.

    MaskableGraphic.cs line 247:
    Code (CSharp):
    2.   private void UpdateClipParent()
    3.         {
    4.             var newParent = (maskable && IsActive()) ? MaskUtilities.GetRectMaskForClippable(this) : null;
    6.             // if the new parent is different OR is now inactive
    7.             if (m_ParentMask != null && (newParent != m_ParentMask || !newParent.IsActive()))
    8.             {
    9.                 m_ParentMask.RemoveClippable(this);
    10.                 UpdateCull(false);
    11.             }
    12. ...
    IsActive() method returns false, and newParent becomes null. As a result cull field set as false.

    So all my content that user haven't seen yet marks as viewed because MaskableGraphic.onCullStateChanged is fired as not culled. Why graphic should be rendered if it is going to be disabled?

    I assume, it's a bug. But maybe there is some reason for such behavior. Obviously, I don't understand something

    Thanks for attention :)
    Last edited: May 8, 2021