/// <summary>
        /// Force revalidate visuals.
        /// </summary>
        /// <returns>true, if visuals were updated.</returns>
        /// <param name="changes">What should be revalidate.</param>
        public override bool UpdateVisuals(GuiDirtyType changes)
        {
            if (!base.UpdateVisuals(changes))
            {
                return(false);
            }

            if ((changes & (GuiDirtyType.Geometry | GuiDirtyType.Panel)) != GuiDirtyType.None)
            {
                if (SpriteAtlas != null && SpriteAtlas.ColorTexture != null)
                {
                    _meshRenderer.sharedMaterial = Panel.GetMaterial(SpriteAtlas);
                    if ((changes & GuiDirtyType.Geometry) != GuiDirtyType.None)
                    {
                        var w       = _isSpriteFlippedHorizontal ? -Width : Width;
                        var h       = _isSpriteFlippedVertical ? -Height : Height;
                        var sprData = SpriteAtlas.GetSpriteData(SpriteName);
                        switch (SpriteType)
                        {
                        case GuiSpriteType.RoundFilled:
                            GuiMeshTools.FillRoundFilledSprite(_meshFilter.sharedMesh, w, h, FillValue, Color, sprData);
                            break;

                        case GuiSpriteType.Sliced:
                        case GuiSpriteType.TiledHorizontal:
                        case GuiSpriteType.TiledVertical:
                        case GuiSpriteType.TiledBoth:
                            var texSize    = new Vector2(SpriteAtlas.ColorTexture.width, SpriteAtlas.ColorTexture.height);
                            var isHorTiled = SpriteType == GuiSpriteType.TiledBoth || SpriteType == GuiSpriteType.TiledHorizontal;
                            var isVerTiled = SpriteType == GuiSpriteType.TiledBoth || SpriteType == GuiSpriteType.TiledVertical;
                            GuiMeshTools.FillSlicedTiledSprite(
                                _meshFilter.sharedMesh, w, h, Color, sprData,
                                texSize, isHorTiled, isVerTiled, IsSpriteCenterFilled);
                            break;

                        default:
                            GuiMeshTools.FillSimpleSprite(_meshFilter.sharedMesh, w, h, Color, sprData);
                            break;
                        }
                    }
                }
                else
                {
                    _meshFilter.sharedMesh.Clear(true);
                }
            }
            return(true);
        }
        void OnEnable()
        {
            if (_meshFilter == null)
            {
                _meshFilter = GetComponent <MeshFilter> ();
            }
            _meshFilter.hideFlags = HideFlags.HideInInspector;

            if (_meshFilter.sharedMesh == null)
            {
                _meshFilter.sharedMesh = GuiMeshTools.GetNewMesh();
            }

            if (_meshRenderer == null)
            {
                _meshRenderer = GetComponent <MeshRenderer> ();
            }
            _meshRenderer.hideFlags = HideFlags.HideInInspector;

            // Force generate geometry.
            SetDirty(GuiDirtyType.All);
        }