Beispiel #1
0
    //-----------------------------------------------------
    public void SetValue(float v)
    {
        m_CurrentValue = Mathf.Clamp(v, m_MinValue, m_MaxValue);

        // Set new position and size of sprite

        Transform trans = transform;
        Vector3   pos   = trans.position;
        Vector3   scale = trans.lossyScale;

        float f = (m_CurrentValue - m_MinValue) / (m_MaxValue - m_MinValue);

        float posX   = pos.x;
        float posY   = pos.y;
        float width  = m_Widget.GetWidth() * f;
        float height = m_Widget.GetHeight();

        posX -= m_Widget.GetWidth() * 0.5f * scale.x;
        posX += width * 0.5f * scale.x;

        if (m_BarSprite != null)
        {
            m_BarSprite.Widget.UpdateSpritePosAndSize(0, posX, posY, width, height);
        }
    }
Beispiel #2
0
    // GUIVIEW INTERFACE

    protected override void OnViewInit()
    {
        base.OnViewInit();

        GUIBase_Widget items      = GetWidget(ITEMS);
        Transform      itemsTrans = items.transform;

        m_ItemsPosition = itemsTrans.position;
        m_ItemsSize     = new Vector2(items.GetWidth(), items.GetHeight());

        for (int idx = 0; idx < MAX_ITEMS; ++idx)
        {
            GUIBase_Widget root      = itemsTrans.FindChild(string.Format(ITEM_NAME, idx)).GetComponent <GUIBase_Widget>();
            Transform      rootTrans = root.transform;

            Transform image = rootTrans.FindChild(ITEM_IMAGE);
            Transform label = rootTrans.FindChild(ITEM_LABEL);

            Item item = new Item()
            {
                Root                          = root,
                Image                         = image != null?image.GetComponent <GUIBase_Sprite>() : null,
                                        Label = label != null?label.GetComponent <GUIBase_Label>() : null
            };

            m_Items[idx] = item;
        }
    }
Beispiel #3
0
        public void Update(Chat.Message message)
        {
            Id = message.Id;

            if (m_Name != null)
            {
                m_Name.SetNewText(GuiBaseUtils.FixNameForGui(message.Nickname));
            }

            if (m_Text != null)
            {
                m_Text.SetNewText(m_Name == null ? string.Format("{0}: {1}", GuiBaseUtils.FixNameForGui(message.Nickname), message.Text) : message.Text);

                Transform trans = m_Text.transform;
                Vector3   scale = trans.localScale;
                m_Rect.width  = Mathf.RoundToInt(m_Text.textSize.x * scale.x);
                m_Rect.height = Mathf.RoundToInt(m_Text.textSize.y * scale.y);
            }

            if (m_RankIcon != null)
            {
                m_RankIcon.State = string.Format("Rank_{0}", Mathf.Min(message.Rank, m_RankIcon.Count - 1).ToString("D2"));
            }

            if (m_RankText != null)
            {
                m_RankText.SetNewText(message.Rank.ToString());
            }

            if (m_HighlightBkg != null)
            {
                Vector2   pos    = m_HighlightBkg.GetOrigPos();
                Transform trans  = m_HighlightBkg.transform;
                Vector3   scale  = trans.lossyScale;
                int       offset = Mathf.RoundToInt(pos.y - m_Root.GetOrigPos().y);
                int       width  = Mathf.RoundToInt(m_HighlightBkg.GetWidth());
                int       height = (int)m_Rect.height + 4;

                offset -= offset - Mathf.RoundToInt(m_HighlightBkg.GetHeight() * 0.5f * scale.y);
                pos.y   = pos.y - offset + height * 0.5f * scale.y;

                m_HighlightBkg.UpdateSpritePosAndSize(0, pos.x, pos.y, width, height);

                m_Rect.width = Mathf.RoundToInt(width * scale.x);
                //m_Rect.height = Mathf.RoundToInt(height * scale.y);
            }

            foreach (var button in m_Buttons)
            {
                Transform trans = button.transform;
                Vector3   pos   = trans.localPosition;

                pos.y = m_Rect.height * 0.5f;
                trans.localPosition = pos;
            }

            m_HoverButton = null;
        }
Beispiel #4
0
    //---------------------------------------------------------
    void CustomInit()
    {
        // prepare sprite for slider bar
        Transform trans = transform;
        Vector3   pos   = trans.position;
        Vector3   scale = trans.lossyScale;
        Vector3   rot   = trans.eulerAngles;

        barWidth  = m_Widget.GetWidth();
        barHeight = m_Widget.GetHeight();

        Texture texture = m_Widget.GetTexture();

        int texWidth  = 1;
        int texHeight = 1;

        if (texture)
        {
            texWidth  = texture.width;
            texHeight = texture.height;
        }

        int texU = 0;
        int texV = 0;
        int texW = 1;
        int texH = 1;

        if (m_BarSprite)
        {
            GUIBase_Widget barW = m_BarSprite.Widget;

            if (barW)
            {
                barWidth  = barW.GetWidth();
                barHeight = barW.GetHeight();

                texU = (int)(texWidth * barW.m_InTexPos.x);
                texV = (int)(texHeight * barW.m_InTexPos.y);
                texW = (int)(texWidth * barW.m_InTexSize.x);
                texH = (int)(texHeight * barW.m_InTexSize.y);

                m_Widget.AddSprite(new Vector2(pos.x, pos.y), barWidth, barHeight, scale.x, scale.y, rot.z, texU, texV + texH, texW, texH);
            }
        }

        // Set initial value
        SetValue(m_InitValue);

        // Hide bar sprite
        m_Widget.ShowSprite(1, false);
    }
Beispiel #5
0
    // ---------
    protected override bool OnInit()
    {
        if (base.OnInit() == false)
        {
            return(false);
        }

        GUIBase_Pivot pivotMain = MFGuiManager.Instance.GetPivot(s_PivotMainName);

        if (!pivotMain)
        {
            Debug.LogError("'" + s_PivotMainName + "' not found!!! Assert should come now");
            return(false);
        }
        GUIBase_Layout layoutMain = pivotMain.GetLayout(s_LayoutMainName);

        if (!layoutMain)
        {
            Debug.LogError("'" + s_LayoutMainName + "' not found!!! Assert should come now");
            return(false);
        }

        m_EnemyLabel              = layoutMain.GetWidget("EnemyName").GetComponent <GUIBase_Widget>();
        m_EnemyLabelName          = layoutMain.GetWidget("EnemyNameLbl").GetComponent <GUIBase_Label>();
        m_EnemyLabelNameOrigScale = 0.7f;         //m_EnemyLabelName.transform.localScale.x;
        m_EnemyLabelOrigWidth     = m_EnemyLabel.GetWidth();

        m_PrepareForFire  = layoutMain.GetWidget("PrepareForFire").GetComponent <GUIBase_Widget>();
        m_PrepareForFireA = layoutMain.GetWidget("PrepareForFireA").GetComponent <GUIBase_Widget>();
        m_PrepareForFireB = layoutMain.GetWidget("PrepareForFireB").GetComponent <GUIBase_Widget>();

        for (int idx = 0; idx < (int)E_CrosshairType.Max; ++idx)
        {
            if (s_CrosshairName.Length <= idx)
            {
                Debug.LogError("Crosshair names mishmash; there is not any name for " + (E_CrosshairType)idx + " crosshair specified !!!");
                break;
            }
            m_Crosshair[idx] = PrepareSprite(layoutMain, s_CrosshairName[idx]);
        }
        //m_CrosshairTargetChilds = m_Crosshair[(int)E_CrosshairType.Target].GetComponentsInChildren<GUIBase_Widget>();

        m_CrosshairHit          = PrepareSprite(layoutMain, s_CrosshairHit);
        m_CrosshairHitTransform = m_CrosshairHit.transform;
        m_CrosshairType         = E_CrosshairType.None;

        m_MeleeRange = false;

        return(true);
    }
Beispiel #6
0
    //---------------------------------------------------------
    Rect GetRect()
    {
#if UNITY_EDITOR
        GUIBase_Widget widget = Widget != null ? Widget : GetComponent <GUIBase_Widget>();
#else
        GUIBase_Widget widget = Widget;
#endif
        if (widget == null)
        {
            return(default(Rect));
        }

        Transform trans      = transform;
        Vector3   lossyScale = trans.lossyScale;
        Vector3   pos        = GetLeftUpPos(trans.position, widget.GetWidth(), widget.GetHeight(), lossyScale);
        float     width      = widget.GetWidth() * lossyScale.x;
        float     height     = widget.GetHeight() * lossyScale.y;
        return(new Rect(
                   pos.x,
                   pos.y,
                   width,
                   height
                   ));
    }
Beispiel #7
0
    // ------
    public void Relink(GUIBase_Widget newParent, GUIBase_Widget imagesDummy = null)
    {
        Parent.Relink(newParent);
        float xScale = newParent.GetWidth() / Parent.GetWidth();
        float yScale = newParent.GetHeight() / Parent.GetHeight();

        if (imagesDummy != null)
        {
            float xScale2 = imagesDummy.GetWidth() / Images.Widget.GetWidth();
            float yScale2 = imagesDummy.GetHeight() / Images.Widget.GetHeight();
            Images.transform.localScale = new Vector3(1 / xScale * xScale2, 1 / yScale * yScale2, 1);
        }

        Parent.transform.localScale = new Vector3(xScale, yScale, 1);
        if (imagesDummy != null)
        {
            Images.transform.position = imagesDummy.transform.position;
        }
    }
Beispiel #8
0
    void SetProgress(string nameFg, string nameBg, int current, int max)
    {
        GUIBase_Widget widgetBg = Layout.GetWidget(nameBg);
        GUIBase_Widget widgetFg = Layout.GetWidget(nameFg);

        Transform emptyTrans = widgetBg.transform;
        Vector3   pos        = emptyTrans.localPosition;
        Vector3   scale      = emptyTrans.localScale;
        float     width      = widgetBg.GetWidth();
        float     ratio      = Mathf.Clamp(current / (float)max, 0.01f, 1.0f);

        pos.x   -= (width - width * ratio) * scale.x * 0.5f;
        scale.x *= ratio;

        Transform fullTrans = widgetFg.transform;

        fullTrans.localScale    = scale;
        fullTrans.localPosition = pos;
        widgetFg.SetModify();
    }
    void UpdateXp(PlayerPersistantInfo ppi, bool reset)
    {
        if (GuiFrontendMain.IsVisible == false)
        {
            return;
        }

        int xp    = ppi != null ? ppi.Experience : 0;
        int level = PlayerPersistantInfo.GetPlayerRankFromExperience(xp);

        if (reset == false)
        {
            SetLabelValue(m_LevelLabel, m_Rank, level, AnimateRank);
            m_Rank = level;
        }
        else
        {
            m_LevelLabel.SetNewText(level.ToString());
        }

        int minXp = PlayerPersistantInfo.GetPlayerMinExperienceForRank(Mathf.Clamp(level, 1, PlayerPersistantInfo.MAX_RANK));
        int maxXp = PlayerPersistantInfo.GetPlayerMinExperienceForRank(Mathf.Clamp(level + 1, 1, PlayerPersistantInfo.MAX_RANK));

        m_LevelPic.State = string.Format("Rank_{0}", Mathf.Min(level, m_LevelPic.Count - 1).ToString("D2"));
        m_XPLabel.SetNewText(xp.ToString() + "/" + maxXp.ToString());

        Transform emptyTrans = m_EmptyBar.transform;
        Vector3   pos        = emptyTrans.localPosition;
        Vector3   scale      = emptyTrans.localScale;
        float     width      = m_EmptyBar.GetWidth();
        float     ratio      = minXp != maxXp?Mathf.Clamp((xp - minXp) / (float)(maxXp - minXp), 0.01f, 1.0f) : 0.0f;

        pos.x   -= (width - width * ratio) * scale.x * 0.5f;
        scale.x *= ratio;

        Transform fullTrans = m_FullBar.transform;

        fullTrans.localScale    = scale;
        fullTrans.localPosition = pos;
        m_FullBar.SetModify();
    }
        void SetProgress(float current)
        {
            if (current > 0.0f)
            {
                Transform emptyTrans = m_ScoreBarBg.transform;
                Vector3   pos        = emptyTrans.localPosition;
                Vector3   scale      = emptyTrans.localScale;
                float     width      = m_ScoreBarBg.GetWidth();
                float     ratio      = Mathf.Clamp(0.1f + current * 0.9f, 0.1f, 1.0f);

                pos.x   += (width - width * ratio) * scale.x * 0.5f;
                scale.x *= ratio;

                Transform fullTrans = m_ScoreBarFg.transform;
                fullTrans.localScale    = scale;
                fullTrans.localPosition = pos;
                m_ScoreBarFg.SetModify();
            }

            m_ScoreBarBg.Show(current > 0.0f ? true : false, true);
            m_ScoreBarFg.Show(current > 0.0f ? true : false, true);
        }
    // MONOBEHAVIOUR INTERFACE

    void Awake()
    {
        m_Label = GetComponent <GUIBase_Label>();

        GUIBase_Widget widget = GetComponent <GUIBase_Widget>();

        if (widget != null)
        {
            widget.RegisterUpdateDelegate(RegenerateBoundaries);

#if UNITY_EDITOR
            if (m_Width <= 0)
            {
                m_Width = Mathf.RoundToInt(widget.GetWidth());
            }
            if (m_Height <= 0)
            {
                m_Height = Mathf.RoundToInt(widget.GetHeight());
            }
#endif
        }
    }
Beispiel #12
0
    //---------------------------------------------------------
    void CustomInit()
    {
        //m_GuiRenderer	= m_Widget.GetGuiRenderer();

        m_MaxCount = Mathf.Clamp(m_MaxCount, 1, MAX_COUNT);

        Transform trans  = transform;
        Vector3   scale  = trans.lossyScale;
        float     width  = m_Widget.GetWidth() / m_MaxCount;
        float     height = m_Widget.GetHeight();

        float   halfWidth = m_Widget.GetWidth() * scale.x / 2.0f;
        Vector3 deltaPos  = new Vector3(halfWidth, 0.0f, 0.0f);
        Vector2 d         = new Vector2();

        d = deltaPos / (m_MaxCount * 0.5f);

        Vector3 leftPos = new Vector3();

        leftPos = trans.position - deltaPos;

        for (int idx = 0; idx < m_MaxCount; ++idx)
        {
            m_Widget.AddSprite(new Vector2(leftPos.x + (idx + 0.5f) * d.x, leftPos.y + (idx + 0.5f) * d.y),
                               width,
                               height,
                               scale.x,
                               scale.y,
                               0.0f,
                               0,
                               0,
                               1,
                               1);
        }

        // Prepare UV for sprites

        if (m_UsedSprites.Length > 0)
        {
            // prepare array for used sprites
            m_UsedSpritesUV = new S_SpriteUV[m_UsedSprites.Length];

            for (int i = 0; i < m_UsedSprites.Length; ++i)
            {
                if (m_UsedSprites[i])
                {
                    GUIBase_Widget tmpW = m_UsedSprites[i].GetComponent <GUIBase_Widget>();

                    if (tmpW)
                    {
                        float UVLeft;
                        float UVTop;
                        float UVWidth;
                        float UVHeight;

                        tmpW.GetTextureCoord(out UVLeft, out UVTop, out UVWidth, out UVHeight);

                        m_UsedSpritesUV[i].m_LowerLeftUV  = new Vector2(UVLeft, 1.0f - (UVTop + UVHeight));
                        m_UsedSpritesUV[i].m_UvDimensions = new Vector2(UVWidth, UVHeight);
                    }
                }
            }
        }
    }
Beispiel #13
0
    public Vector3 GetLeftUpPos(GUIBase_Widget inWidget, Vector3 scale)
    {
        Transform trans = transform;

        return(GetLeftUpPos(trans.position, inWidget.GetWidth(), inWidget.GetHeight(), scale));
    }
Beispiel #14
0
    //---------------------------------------------------------
    void RegenerateSprites()
    {
        if (IsDataRegenerationNeaded() == false || m_Widget.IsVisible() == false)
        {
            return;
        }

        // regenerate runtime data for new text...
        GenerateRunTimeData();

        string text = Text;

        if (string.IsNullOrEmpty(text) == false && m_Uppercase)
        {
            text = text.ToUpper();
        }

        // destroy old text if any exist...
        m_Widget.PrepareSprites(string.IsNullOrEmpty(text) == true ? 0 : text.Length);

        if (string.IsNullOrEmpty(text) == false && text.Length > 0)
        {
            Vector3 scale = Vector3.one;

            Texture texture = fontTexture;

            int texWidth  = texture ? texture.width : 1;
            int texHeight = texture ? texture.height : 1;

            float lineHeight = m_LineSize.y * texHeight;
            float lineWidth  = m_LineSize.x;
            float widthMult  = m_Widget.GetWidth() / lineWidth;

            // compute down scale if needed
            if (m_Boundaries.IsEmpty() == false)
            {
                Rect clientRect = GetRect();
                Rect rect       = m_Boundaries.Intersect(clientRect);

                float scaleX = rect.width / clientRect.width;
                float scaleY = rect.height / clientRect.height;

                if (scaleY > scaleX)
                {
                    scaleY = scaleX;
                }
                else
                {
                    scaleX = scaleY;
                }

                scale.x *= scaleX;
                scale.y *= scaleY;
            }

            // setup cursor ...
            Vector2 cursor    = GetLeftUpPos(m_Widget.GetOrigPos(), scale);
            float   lineBegin = cursor.x;
            cursor.y += lineHeight * scale.y * 0.5f;         // textHeight*0.5f;

            bool multiline = IsMultiline(text);

            if (multiline == true)
            {
                cursor = SetupCursorForTextAlign(cursor, text, 0, m_Alignment, font, lineBegin, lineWidth, widthMult * scale.x);
            }

            for (int i = 0; i < text.Length; ++i)
            {
                int character = text[i];
                switch (character)
                {
                case '\n':
                    if (multiline == true)
                    {
                        cursor = SetupCursorForTextAlign(cursor, text, i + 1, m_Alignment, font, lineBegin, lineWidth, widthMult * scale.x);
                    }
                    else
                    {
                        cursor.x = lineBegin;
                    }

                    cursor.y = cursor.y + (lineHeight + lineSpace * texHeight) * scale.y;
                    m_Widget.SetTextureCoords(i, 0.0f, 0.0f, 0.0f, 0.0f);
                    m_Widget.UpdateSpritePosAndSize(i, 0, -Screen.height, 1.0f, 1.0f);
                    m_Widget.ShowSprite(i, false);
                    break;

                default:
                {
                    if (useFontEx == false)
                    {
                        Vector2 inTexPos  = new Vector2();
                        Vector2 inTexSize = new Vector2();
                        float   width;

                        GUIBase_Font fontOld = font as GUIBase_Font;
                        fontOld.GetCharDscr(character, out width, ref inTexPos, ref inTexSize);
                        width *= widthMult;

                        int texU = (int)(texWidth * inTexPos.x);
                        int texV = (int)(texHeight * inTexPos.y);
                        int texW = (int)(texWidth * inTexSize.x);
                        int texH = (int)(texHeight * inTexSize.y);

                        cursor.x += 0.5f * width * scale.x;
                        m_Widget.SetTextureCoords(i, texU, texV, texW, texH);
                        m_Widget.UpdateSpritePosAndSize(i, cursor.x, cursor.y, width, lineHeight);
                        cursor.x += 0.5f * width * scale.x;
                    }
                    else
                    {
                        float width;
                        Rect  spriteRect, texRect;

                        GUIBase_FontEx fontEx = font as GUIBase_FontEx;

                        if (fontEx.GetCharDescription(text[i], out width, out spriteRect, out texRect, false, false))
                        {
                            width *= widthMult;

                            Vector2 inCharSize = new Vector2(spriteRect.width * scale.x, spriteRect.height /*****/ * texHeight * scale.y);
                            // TODO :: rewite without texHeight...
                            Vector2 inCharCenter = cursor + new Vector2(spriteRect.center.x * scale.x, 0.0f);

                            m_Widget.SetTextureCoords(i, (int)texRect.x, (int)texRect.y, (int)texRect.width, (int)texRect.height);
                            m_Widget.UpdateSpritePosAndSize(i, inCharCenter.x, inCharCenter.y, inCharSize.x, inCharSize.y);
                            cursor.x += width * scale.x;
                        }
                    }
                    break;
                }
                }
            }
        }

        // we have to force widget update.
        m_RegenerationNeeded = false;
        m_Widget.SetModify();
    }
Beispiel #15
0
    //---------------------------------------------------------
    void RegenerateSprites()
    {
        if (m_RegenerateSprites == false || m_Widget.IsVisible() == false)
        {
            return;
        }

        if (m_Font == null)
        {
            m_Font = MFFontManager.GetFont(m_FontName) as GUIBase_FontEx;
            if (m_Font == null)
            {
                Debug.LogError(gameObject.GetFullName() + " Can't load font with name " + m_FontName);
                return;
            }
        }

        if (m_TextID > 0)
        {
            m_Text = TextDatabase.instance[m_TextID];
        }

        // destroy old text if any exist...
        int maxSprites = text != null && text.Length > 0 ? Mathf.CeilToInt(text.Length * 0.1f) * 10 : 0;

        m_Widget.PrepareSprites(maxSprites);

        if (text != null && text.Length > 0)
        {
            Vector3 scale = transform.lossyScale;
            scale = Vector3.one;

            // setup cursor ...
            Vector2 leftUpPos = new Vector2(m_Widget.GetOrigPos().x - m_Widget.GetWidth() * 0.5f * scale.x,
                                            m_Widget.GetOrigPos().y - m_Widget.GetHeight() * 0.5f * scale.y);
            Vector2 cursor = leftUpPos;

            float maxLineSize = m_Widget.GetWidth() * scale.x;

            scale.x = m_TextScale.x;
            scale.y = m_TextScale.y;

            List <TextLine> textLines = GetLines(text, m_Font, alignment, maxLineSize, scale, lineSpace, IsForTextField);
            if (textLines == null || textLines.Count <= 0)
            {
                return;
            }

            float fontHeight = m_Font.GetFontHeight();
            m_TextSize = new Vector2(m_Widget.GetWidth(), textLines.Count * fontHeight * scale.y + (textLines.Count - 1) * lineSpace * fontHeight * scale.y);

            float width;
            Rect  spriteRect, texRect;

            int spriteIdx = 0;
            foreach (TextLine line in textLines)
            {
                cursor = leftUpPos + line.m_Offset;

                for (int i = line.m_StartIndex; i < line.m_EndIndex; ++i)
                {
                    int character = text[i];

                    if (!IsForTextField && character == ' ')
                    {
                        cursor.x += line.m_SpaceWidth;
                        continue;
                    }
                    switch (character)
                    {
                    case '\n':
                        Debug.LogWarning("function GetLines doesn't work correctly");
                        break;

                    default:
                    {
                        if (m_Font.GetCharDescription(text[i], out width, out spriteRect, out texRect, false, false, false))
                        {
                            Vector2 inCharSize   = new Vector2(spriteRect.width * scale.x, spriteRect.height * scale.y);
                            Vector2 inCharCenter = cursor + new Vector2(spriteRect.center.x * scale.x, 0.0f);

                            m_Widget.SetTextureCoords(spriteIdx, (int)texRect.x, (int)texRect.y, (int)texRect.width, (int)texRect.height);
                            m_Widget.UpdateSpritePosAndSize(spriteIdx, inCharCenter.x, inCharCenter.y, inCharSize.x, inCharSize.y);
                            m_Widget.ShowSprite(spriteIdx, true);
                            cursor.x += width * scale.x;

                            spriteIdx++;
                        }
                        break;
                    }
                    }
                }
            }

            // hide all unused sprites
            while (spriteIdx < maxSprites)
            {
                m_Widget.SetTextureCoords(spriteIdx, 0.0f, 0.0f, 0.0f, 0.0f);
                m_Widget.UpdateSpritePosAndSize(spriteIdx, 0.0f, -Screen.height, 1.0f, 1.0f);
                m_Widget.ShowSprite(spriteIdx, false);
                spriteIdx++;
            }
        }

        // we have to force widget update.
        m_RegenerateSprites = false;
        m_Widget.SetModify();
    }
Beispiel #16
0
    //-----------------------------------------------------
    void SetNumber(int number, int max, bool force)
    {
        if (m_Value == number && false == force)
        {
            return;
        }

        int absNumber = Mathf.Abs(number);

        if (absNumber > max)
        {
            absNumber = max;
        }

        m_Value = number;

        int div1 = 1;
        int div2 = 10;

        int visibleDigits = 0;

        for (int digitIdx = 0; digitIdx < numberDigits; ++digitIdx)
        {
            int rest = (absNumber % div2) / div1;

            if ((absNumber > (div1 - 1)) || (digitIdx == 0) || m_KeepZeros)
            {
                // Show digit
                m_Widget.ShowSprite(digitIdx, true);

                // set correct UV
                MFGuiSprite   s        = m_Widget.GetSprite(digitIdx);
                MFGuiUVCoords uvCoords = s.uvCoords;
                uvCoords.U = m_UvLeft + m_UvWidth * rest;
                uvCoords.V = 1.0f - (m_UvTop + m_UvHeight);
                s.uvCoords = uvCoords;

                visibleDigits++;
            }
            else
            {
                // Hide digit
                m_Widget.ShowSprite(digitIdx, false);
            }

            div1  = div2;
            div2 *= 10;
        }

        if (visibleDigits == 0)
        {
            return;
        }
        if (visibleDigits == m_LastVisibleDigits && force == false)
        {
            return;
        }
        m_LastVisibleDigits = visibleDigits;

        Transform trans = transform;
        Vector3   scale = trans.lossyScale;

        float   width     = m_Widget.GetWidth() / numberDigits;
        float   height    = m_Widget.GetHeight();
        float   halfWidth = m_Widget.GetWidth() * scale.x * 0.5f;
        Vector3 deltaPos  = new Vector3(halfWidth, 0.0f);
        Vector3 rightPos  = m_Widget.GetOrigPos() + deltaPos;

        Vector3 delta;

        switch (m_Alignment)
        {
        case TextAlignment.Left:
            delta       = deltaPos / (numberDigits * 0.5f);
            rightPos.x -= (numberDigits - visibleDigits) * delta.x;
            break;

        case TextAlignment.Center:
            delta = deltaPos / (visibleDigits * 0.5f);
            break;

        default:
            delta = deltaPos / (numberDigits * 0.5f);
            break;
        }

        for (int idx = 0; idx < visibleDigits; ++idx)
        {
            m_Widget.UpdateSpritePosAndSize(idx, rightPos.x - (idx + 0.5f) * delta.x, rightPos.y - (idx + 0.5f) * delta.y, width, height);
        }
    }