internal void _PreUpdateMask(UpdateContext context, uint maskId)
        {
            //_maskFlag: 0-new mask, 1-active mask, 2-mask complete
            if (_maskFlag == 0)
            {
                if (_stencilEraser == null)
                {
                    _stencilEraser = new StencilEraser(gameObject.transform);
                    _stencilEraser.meshFilter.mesh = mesh;
                }
                else
                {
                    _stencilEraser.enabled = true;
                }
            }

            _maskFlag = 1;

            if (_manager != null)
            {
                //这里使用maskId而不是clipInfo.clipId,是因为遮罩有两个用途,一个是写入遮罩,一个是擦除,两个不能用同一个材质
                Material mat = _manager.GetMaterial((int)MaterialFlags.AlphaMask + _materialFlags, BlendMode.Normal, maskId);
                if (!Material.ReferenceEquals(mat, _stencilEraser.meshRenderer.sharedMaterial))
                {
                    _stencilEraser.meshRenderer.sharedMaterial = mat;
                }

                context.ApplyAlphaMaskProperties(mat, true);
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="context"></param>
        /// <param name="alpha"></param>
        /// <param name="grayed"></param>
        public void Update(UpdateContext context, float alpha, bool grayed)
        {
            Stats.GraphicsCount++;

            if (_meshDirty)
            {
                _alpha = alpha;
                UpdateMeshNow();
            }
            else if (_alpha != alpha)
            {
                ChangeAlpha(alpha);
            }

            if (_propertyBlock != null && _blockUpdated)
            {
                meshRenderer.SetPropertyBlock(_propertyBlock);
                _blockUpdated = false;
            }

            if (_customMatarial != 0)
            {
                if ((_customMatarial & 2) != 0 && _material != null)
                {
                    context.ApplyClippingProperties(_material, false);
                }
            }
            else
            {
                if (_manager != null)
                {
                    if (_maskFlag == 1)
                    {
                        _material = _manager.GetMaterial((int)MaterialFlags.AlphaMask + _materialFlags, BlendMode.Normal, context.clipInfo.clipId);
                        context.ApplyAlphaMaskProperties(_material, false);
                    }
                    else
                    {
                        int matFlags = _materialFlags;
                        if (grayed)
                        {
                            matFlags |= (int)MaterialFlags.Grayed;
                        }

                        if (context.clipped)
                        {
                            if (context.stencilReferenceValue > 0)
                            {
                                matFlags |= (int)MaterialFlags.StencilTest;
                            }
                            if (context.rectMaskDepth > 0)
                            {
                                if (context.clipInfo.soft)
                                {
                                    matFlags |= (int)MaterialFlags.SoftClipped;
                                }
                                else
                                {
                                    matFlags |= (int)MaterialFlags.Clipped;
                                }
                            }

                            _material = _manager.GetMaterial(matFlags, blendMode, context.clipInfo.clipId);
                            if (_manager.firstMaterialInFrame)
                            {
                                context.ApplyClippingProperties(_material, true);
                            }
                        }
                        else
                        {
                            _material = _manager.GetMaterial(matFlags, blendMode, 0);
                        }
                    }
                }
                else
                {
                    _material = null;
                }

                if (!Material.ReferenceEquals(_material, meshRenderer.sharedMaterial))
                {
                    meshRenderer.sharedMaterial = _material;
                }
            }

            if (_maskFlag != 0)
            {
                if (_maskFlag == 1)
                {
                    _maskFlag = 2;
                }
                else
                {
                    if (_stencilEraser != null)
                    {
                        _stencilEraser.enabled = false;
                    }

                    _maskFlag = 0;
                }
            }
        }