UIWidget.UpdateGeometry C# (CSharp) Method

UpdateGeometry() public method

Update the widget and fill its geometry if necessary. Returns whether something was changed.
public UpdateGeometry ( Matrix4x4 &worldToPanel, bool parentMoved, bool generateNormals ) : bool
worldToPanel Matrix4x4
parentMoved bool
generateNormals bool
return bool
    public bool UpdateGeometry(ref Matrix4x4 worldToPanel, bool parentMoved, bool generateNormals)
    {
        if (material == null) return false;

        if (OnUpdate() || mChanged)
        {
            mChanged = false;
            mGeom.Clear();
            OnFill(mGeom.verts, mGeom.uvs, mGeom.cols);

            if (mGeom.hasVertices)
            {
                Vector3 offset = pivotOffset;
                Vector2 scale = relativeSize;

                offset.x *= scale.x;
                offset.y *= scale.y;

                mGeom.ApplyOffset(offset);
                mGeom.ApplyTransform(worldToPanel * cachedTransform.localToWorldMatrix, generateNormals);
            }
            return true;
        }
        else if (mGeom.hasVertices && parentMoved)
        {
            mGeom.ApplyTransform(worldToPanel * cachedTransform.localToWorldMatrix, generateNormals);
        }
        return false;
    }

Usage Example

Esempio n. 1
0
    private void UpdateWidgets()
    {
        bool flag  = false;
        bool flag2 = false;
        bool hasCumulativeClipping = this.hasCumulativeClipping;

        if (!this.cullWhileDragging)
        {
            for (int i = 0; i < UIScrollView.list.size; i++)
            {
                UIScrollView uIScrollView = UIScrollView.list[i];
                if (uIScrollView.panel == this && uIScrollView.isDragging)
                {
                    flag2 = true;
                }
            }
        }
        if (this.mForced != flag2)
        {
            this.mForced  = flag2;
            this.mResized = true;
        }
        int frameCount = Time.frameCount;
        int j          = 0;
        int count      = this.widgets.Count;

        while (j < count)
        {
            UIWidget uIWidget = this.widgets[j];
            if (uIWidget.panel == this && uIWidget.enabled)
            {
                if (uIWidget.UpdateTransform(frameCount) || this.mResized)
                {
                    bool visibleByAlpha = flag2 || uIWidget.CalculateCumulativeAlpha(frameCount) > 0.001f;
                    uIWidget.UpdateVisibility(visibleByAlpha, flag2 || (!hasCumulativeClipping && !uIWidget.hideIfOffScreen) || this.IsVisible(uIWidget));
                }
                if (uIWidget.UpdateGeometry(frameCount))
                {
                    flag = true;
                    if (!this.mRebuild)
                    {
                        if (uIWidget.drawCall != null)
                        {
                            uIWidget.drawCall.isDirty = true;
                        }
                        else
                        {
                            this.FindDrawCall(uIWidget);
                        }
                    }
                }
            }
            j++;
        }
        if (flag && this.onGeometryUpdated != null)
        {
            this.onGeometryUpdated();
        }
        this.mResized = false;
    }
All Usage Examples Of UIWidget::UpdateGeometry