Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Sprite Borders + Mip maps issue on iOS (RC3)

Discussion in 'UGUI & TextMesh Pro' started by andsee, Nov 25, 2014.

  1. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    Just incase you're wondering why slicing isn't showing you what you expect check you do not have the following set of circumstances as it appears that there is an issue with the following:
    • Build platform is set to iOS
    • Non power of 2 sprite
    • Mip maps enabled
    • Sprite part of sprite packer atlas (allowing use of non square mip mapped sprites)
    • Use sprite in an image with Tiling or Slicing
    As you can see below the image does not tile properly and gains an area of white (highlighted) not present in the atlas. Looking into this further and it is evident that the editor is using a padded non atlased sprite while in edit mode.
    Untitled_-_Unity_-_iPhone__iPod_Touch_and_iPad 3.png
    I added the following script to show the UVs used by the Image component and in the right hand column of the above image you can see that the inner UVs are being reported outside of the outer UVs. It appears the outer UVs are correct for the padded sprite but the inner UVs are for a non padded sprite.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. public class ShowBounds : MonoBehaviour {
    4.  
    5.     public Sprite sprite;
    6.     public Vector4 inner;
    7.     public Vector4 outer;
    8.     void OnValidate ()
    9.     {
    10.         if(sprite != null)
    11.         {          
    12.             inner = UnityEngine.Sprites.DataUtility.GetInnerUV(sprite);
    13.             outer = UnityEngine.Sprites.DataUtility.GetOuterUV(sprite);
    14.         }
    15.     }
    16. }
    17.  
    Fortunately when you switch to play mode or switch the platform to PC or Mac both UVs change to match the position in the atlas and everything is rendered correctly. But this does mean that if you make use of mip maps and non power of two textures you can not edit while the platform is set to iOS.

    Untitled_-_Unity_-_iPhone__iPod_Touch_and_iPad 4.png
     
    Last edited: Nov 25, 2014
  2. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    A quick update. I've just been creating builds and Unity managed to get into a state where builds and running in editor kept the bad inner uvs for the texture! I 'fixed' it by deleting the library folder and hence forcing Unity to recreate it's cached data. Perhaps I could have tried repack, if it occurs again I will.

    Bug submitted as case 650986
     
  3. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    Sorry it took so long but we will have this fixed in a patch release shortly.
     
    andsee likes this.
  4. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Thanks this is great news, hope we see this working next patch.
     
  5. andsee

    andsee

    Joined:
    Mar 20, 2012
    Posts:
    88
    Fantastic news, Its been a real pain having to constantly switch platforms between pc/mac and mobile, I assume you spotted that the issue also occurs with the platform set to Android on a PC.
     
  6. TomasJ

    TomasJ

    Joined:
    Sep 26, 2010
    Posts:
    256
    It was a cross-platform fix.
     
    andsee likes this.