Author Topic: Bug in UIFont?  (Read 2808 times)

rtargosz

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Bug in UIFont?
« on: February 12, 2014, 09:56:26 AM »
I suspect there are bugs/typos in the uvRect getter (segment below) for UIFont. Note that you've checked to see that mSprite IS NULL before entering the section that then uses mSprite's member variables. I suspect you meant mSprite != null OR perhaps all references to mSprite were supposed to be sprite? In either case, either "mSprite" or "sprite" won't be referenced at all in the getter, so why are you checking both?

   public Rect uvRect
   {
      get
      {
         if (mReplacement != null) return mReplacement.uvRect;

         if (mAtlas != null && (mSprite == null && sprite != null))
         {
            Texture tex = mAtlas.texture;

            if (tex != null)
            {
               mUVRect = new Rect(
                  mSprite.x - mSprite.paddingLeft,
                  mSprite.y - mSprite.paddingTop,
                  mSprite.width + mSprite.paddingLeft + mSprite.paddingRight,
                  mSprite.height + mSprite.paddingTop + mSprite.paddingBottom);
...
Thanks,
-Rob

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Bug in UIFont?
« Reply #1 on: February 13, 2014, 01:11:31 AM »
This is intentional. The first check (mSprite == null) is to ensure that I only do the next part if the sprite reference has not yet been set. The second part (sprite != null) is what actually attempts to retrieve the sprite. If the sprite gets retrieved, the result of the statement will be 'true'.

So the statement reads: if the sprite hasn't been set, but it can be retrieved, do stuff.