Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Graphics Sprite Renderer Issues in Build (b21)

Discussion in '5.4 Beta' started by JasonBricco, Jun 14, 2016.

  1. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I had made another topic about instantiation freezing issues and sprite issues. The instantiation issues are fixed, and so I thought it would be better to put this issue in its own topic and see if anyone else has any ideas about what's going on.

    Here's an image from a platformer (using asset store art for prototyping):

    Monosnap 2016-06-14 17-08-23.png

    When I update an image in the UI by changing its sprite through code (using the Recompute function here):

    Code (CSharp):
    1. public sealed class HealthDisplay : MonoBehaviour
    2. {
    3.     [SerializeField] private Sprite[] sprites;
    4.     private Image[] hearts;
    5.  
    6.     private void Awake()
    7.     {
    8.         hearts = GetComponentsInChildren<Image>();
    9.     }
    10.  
    11.     public void Recompute(int health)
    12.     {
    13.         for (int i = 0; i < hearts.Length; i++)
    14.         {
    15.             health = Mathf.Max(health, 0);
    16.  
    17.             if (health >= 4)
    18.             {
    19.                 hearts[i].sprite = sprites[4];
    20.                 health -= 4;
    21.                 continue;
    22.             }
    23.  
    24.             hearts[i].sprite = sprites[health];
    25.             health = 0;
    26.         }
    27.     }
    28. }
    I end up with the tree sprite becoming enlarged in the corner of the screen:

    Monosnap 2016-06-14 17-08-37.png

    This flashes for a brief moment. It almost seems like the images are trying to move from the corner to their actual positions.

    The code above is updating heart sprites to show how much remaining health the character has. Changing the sprites is specifically what makes this happen.

    The interesting part is that this only happens in builds, never in the Unity editor.

    It happens both in debug and release builds on my Mac (El Capitan, 64 bit) as well as on the build I sent my friend with Windows 7.

    What's going on here?
     
  2. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    I have found the source, I believe. It's the experimental "graphics jobs" option in the player settings. Turning that off seems to have fixed it (as well as a massive Camera.render culling spike that was going on from it.)
     
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    So really this option is so far broken, maybe can send them a bug report and may improve on the issue.?
     
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,650
    Please submit a bug-report for that, otherwise it might not get fixed.
     
  5. JasonBricco

    JasonBricco

    Joined:
    Jul 15, 2013
    Posts:
    956
    Once I can set up a smaller project for testing today, I sure will.
     
    Peter77 likes this.