Esempio n. 1
0
    public bool UpdateGeometry(ref Matrix4x4 worldToPanel, bool parentMoved, bool generateNormals)
    {
        if (this.material == null)
        {
            return(false);
        }
        UIGeometry mGeom = this.mGeom;

        if ((!this.OnUpdate() && !this.mChangedCall) && !this.mForcedChanged)
        {
            if (mGeom.hasVertices && parentMoved)
            {
                Matrix4x4 widgetToPanel = worldToPanel * this.cachedTransform.localToWorldMatrix;
                mGeom.Apply(ref widgetToPanel);
            }
            return(false);
        }
        this.mChangedCall   = false;
        this.mForcedChanged = false;
        mGeom.Clear();
        if (this.mAlphaUnchecked || !NGUITools.ZeroAlpha(this.mColor.a))
        {
            this.OnFill(mGeom.meshBuffer);
        }
        if (mGeom.hasVertices)
        {
            Vector3 vector;
            Vector2 vector2;
            Vector2 vector3;
            switch (((WidgetFlags)((byte)(this.widgetFlags & (WidgetFlags.CustomPivotOffset | WidgetFlags.CustomRelativeSize)))))
            {
            case WidgetFlags.CustomPivotOffset:
                tempWidgetFlags[0] = WidgetFlags.CustomPivotOffset;
                this.GetCustomVector2s(0, 1, tempWidgetFlags, tempVector2s);
                vector2   = tempVector2s[0];
                vector3.x = vector3.y = 1f;
                break;

            case WidgetFlags.CustomRelativeSize:
                tempWidgetFlags[0] = WidgetFlags.CustomRelativeSize;
                this.GetCustomVector2s(0, 1, tempWidgetFlags, tempVector2s);
                vector3 = tempVector2s[0];
                vector2 = DefaultPivot(this.mPivot);
                break;

            case (WidgetFlags.CustomPivotOffset | WidgetFlags.CustomRelativeSize):
                tempWidgetFlags[0] = WidgetFlags.CustomPivotOffset;
                tempWidgetFlags[1] = WidgetFlags.CustomRelativeSize;
                this.GetCustomVector2s(0, 2, tempWidgetFlags, tempVector2s);
                vector2 = tempVector2s[0];
                vector3 = tempVector2s[1];
                break;

            default:
                vector2   = DefaultPivot(this.mPivot);
                vector3.x = vector3.y = 1f;
                break;
            }
            vector.x = vector2.x * vector3.x;
            vector.y = vector2.y * vector3.y;
            vector.z = 0f;
            Matrix4x4 matrixx = worldToPanel * this.cachedTransform.localToWorldMatrix;
            mGeom.Apply(ref vector, ref matrixx);
        }
        return(true);
    }
Esempio n. 2
0
    public bool UpdateGeometry(ref Matrix4x4 worldToPanel, bool parentMoved, bool generateNormals)
    {
        Vector3 vector3 = new Vector3();
        Vector2 vector2;
        Vector2 vector21 = new Vector2();
        float   single;

        if (!this.material)
        {
            return(false);
        }
        UIGeometry uIGeometry = this.mGeom;

        if (!this.OnUpdate() && !this.mChangedCall && !this.mForcedChanged)
        {
            if (uIGeometry.hasVertices && parentMoved)
            {
                Matrix4x4 matrix4x4 = worldToPanel * this.cachedTransform.localToWorldMatrix;
                uIGeometry.Apply(ref matrix4x4);
            }
            return(false);
        }
        this.mChangedCall   = false;
        this.mForcedChanged = false;
        uIGeometry.Clear();
        if (this.mAlphaUnchecked || !NGUITools.ZeroAlpha(this.mColor.a))
        {
            this.OnFill(uIGeometry.meshBuffer);
        }
        if (uIGeometry.hasVertices)
        {
            switch ((byte)(this.widgetFlags & (UIWidget.WidgetFlags.CustomPivotOffset | UIWidget.WidgetFlags.CustomRelativeSize)))
            {
            case 1:
            {
                UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomPivotOffset;
                this.GetCustomVector2s(0, 1, UIWidget.tempWidgetFlags, UIWidget.tempVector2s);
                vector2 = UIWidget.tempVector2s[0];
                float single1 = 1f;
                single     = single1;
                vector21.y = single1;
                vector21.x = single;
                break;
            }

            case 2:
            {
                UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomRelativeSize;
                this.GetCustomVector2s(0, 1, UIWidget.tempWidgetFlags, UIWidget.tempVector2s);
                vector21 = UIWidget.tempVector2s[0];
                vector2  = UIWidget.DefaultPivot(this.mPivot);
                break;
            }

            case 3:
            {
                UIWidget.tempWidgetFlags[0] = UIWidget.WidgetFlags.CustomPivotOffset;
                UIWidget.tempWidgetFlags[1] = UIWidget.WidgetFlags.CustomRelativeSize;
                this.GetCustomVector2s(0, 2, UIWidget.tempWidgetFlags, UIWidget.tempVector2s);
                vector2  = UIWidget.tempVector2s[0];
                vector21 = UIWidget.tempVector2s[1];
                break;
            }

            default:
            {
                vector2 = UIWidget.DefaultPivot(this.mPivot);
                float single2 = 1f;
                single     = single2;
                vector21.y = single2;
                vector21.x = single;
                break;
            }
            }
            vector3.x = vector2.x * vector21.x;
            vector3.y = vector2.y * vector21.y;
            vector3.z = 0f;
            Matrix4x4 matrix4x41 = worldToPanel * this.cachedTransform.localToWorldMatrix;
            uIGeometry.Apply(ref vector3, ref matrix4x41);
        }
        return(true);
    }