Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: rogercheng on July 22, 2014, 09:04:06 PM

Title: uisprite was clipped when aplha=1
Post by: rogercheng on July 22, 2014, 09:04:06 PM
I encounter an strange bug when working with NGUIv3.0.5
I placed an UIToggel object on a scroll panel. The value of uitoggle was initially set to false, and the "instantTween" property of uitoggle object was also set to false.  The uitoggle object was invisible when the panel showing firstly for it's was out of clipping area. Then I scroll the panel in order to show the toggle. Surely, it's in visible range. So I click uitoggle object in hope of the checkSprite of uitoggle becoming visible, instead it's not showed. I checked the alpha of checkSprite  and I was sure that it equals 1.0f. If I scroll the panel slightly after that, it would be showed again. I can not understand, and I debug the NGUI source code.

And find this:
// UIWidget.cs

public bool UpdateGeometry (UIPanel p, bool forceVisible)
{
      if (p != null)
      {         
         mPanel = p;
         bool hasMatrix = false;
         float final = finalAlpha;
         bool visibleByAlpha = (final > 0.001f);
         bool visibleByPanel = forceVisible || mVisibleByPanel;

         // Has transform moved?
         if (HasTransformChanged())
         {
                ....
                if (visibleByAlpha || mForceVisible != forceVisible)
            {
                    // debug label 1:
               mForceVisible = forceVisible;
               visibleByPanel = forceVisible || mPanel.IsVisible(this);
            }
                ...
            }
            else if (visibleByAlpha && mForceVisible != forceVisible)
         {
                // debug label 2:
               
            mForceVisible = forceVisible;
            visibleByPanel = mPanel.IsVisible(this);
         }

         // Is the visibility changing?
         if (mVisibleByPanel != visibleByPanel) // i think this conditon should be "visibleByAlpha || mVisibleByPanel != visibleByPanel"
         {
                // debug label 3:
               
            mVisibleByPanel = visibleByPanel;
            mChanged = true;
         }
           
            ....
        }
       
when I click uitoggle, HasTransformChanged()== false, mForceVisible == forceVisible, mVisibleByPanel == visibleByPanel, so label 1, lable 2, lable 3 cannot be reached.
so no changes were made. After that, I scroll the panel, HasTransformChanged()==true, mForceVisible == forceVisible, but visibleByAlpha == true, and label 1 is reached, so mChanged=true.
so I think the condition of label 3 should be "visibleByAlpha || mVisibleByPanel != visibleByPanel" in case of changing aplha merely.

I am hoping for your reply, thank you.
Title: Re: uisprite was clipped when aplha=1
Post by: ArenMook on July 22, 2014, 11:29:10 PM
I'm sorry, but 3.0.5 is extremely out of date. You need to update to the latest version if I am to be of any help to you.