Search Unity

Corrupted sprite

Discussion in '2D' started by Silly_Rollo, Feb 10, 2019.

  1. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    I'm randomly getting these kinds of corrupted sprites sometimes when assigning a sprite to a sprite renderer using the default sprite shader on 2018.3.5f1. There is no animator/animation being used.



    Sometimes it just flashes that and then goes normal but other times it sticks until I assign a different sprite (and then is fine if I go back to the original sprite). It happens with different sprites so it doesn't seem like it's something to do with a particular one. It is a sliced sprite but all the frames look fine and it doesn't ever do it consistently for a certain frame. Not really sure where to start debugging this
     
  2. Venkify

    Venkify

    Unity Technologies

    Joined:
    Apr 7, 2015
    Posts:
    644
    @Silly_Rollo
    Could you please submit a bug with a sample repro project ?
     
  3. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501
    I actually figured the issue out tho I could put it together into a project but I'm not really sure it's a bug per se.

    My animation system runs separate from Unity and once in a great while it'd assign multiple sprites to a renderer in a single Unity frame. These are directional sprites so occasionally a sprite for an animation would get assigned and later in the frame the directional checker would run and if the view direction changed it would assign a different sprite based on the new direction. There was also a bug where it might try to assign the same sprite multiple times in a single frame. These multiple assignments sometimes caused the renderer to spaz out.

    I solved it by removing any access to the renderer from the larger system and only process a single change sprite request (the most recent one) at the end of the frame.
     
  4. Leo-Yaik

    Leo-Yaik

    Unity Technologies

    Joined:
    Aug 13, 2014
    Posts:
    436
    Are you using 9-slice for these images?
     
  5. Silly_Rollo

    Silly_Rollo

    Joined:
    Dec 21, 2012
    Posts:
    501