Hello Guest

Author Topic: Possible Bug: Sprites disappearing and mesh filter empty  (Read 7979 times)

Stanyard

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 1
    • View Profile
Possible Bug: Sprites disappearing and mesh filter empty
« on: May 15, 2013, 04:47:17 pm »
My team has been having an issue as of late with disappearing mesh filters and we're unsure if it's an issue with tk2d, Unity, or something we're goofing up. The issue arises if an object has a prefab and is a child of at least 4 parents in a particular order. After one run of the game the sprite will disappear.

Steps to reproduce in a new Unity project:

  • Import tk2d
  • Import a Texture
  • Create a collection
  • Add the texture as a sprite in that collection
  • Create a tk2d sprite object of that sprite
  • Create a prefab of that object
  • Duplicate the object 4 times
  • Parent the lowest sprite object in the hierarchy to the one above it
  • Then parent that object with the one above it
  • Repeat until you have a stack of 5 sprite objects with the lowest child having the other 4 as parents
  • Run the game.

The lowest child's mesh filter may disappear unless you unparent it and run the game again. The prefab also doesn't have a mesh filter, but that is expected behavior, right?

The order in which objects are parented seem to matter when triggering this bug, which is why I was so precise with the parenting instructions. In fact, if you reorder the child objects after the bug has occurred the bug will seemingly vanish. Keep reordering them and eventually it'll crop up again. It also doesn't have to be the same object duplicated. I tested with objects each having their own prefab with similar results. If one of the child objects in the line doesn't have a prefab it'll also fix the glitch on occasion.

tk2d version 1.92 + Patch 1
Unity version 4.1.2f1

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Possible Bug: Sprites disappearing and mesh filter empty
« Reply #1 on: May 16, 2013, 10:15:02 am »
Thanks for the comprehensive bug report, but sadly I've not been able to reproduce this. I tried with 10 nested sprites which are prefabs, and still no dice.

Can you create a repro case for me - ideally in the situation where if I open up the scene and run it, there will be a meshfilter missing... support at unikronsoftware.com is the place to send it, if you can.

shiraz

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Possible Bug: Sprites disappearing and mesh filter empty
« Reply #2 on: July 31, 2013, 11:40:06 pm »
Just chiming in here - I run into this at times as well.  It seems to happen

1.  When I create a prefab (could be anything) - call it the "parent" - add to the hierarchy in the scene.
2.  Create a second prefab "child" and nest it under the "parent" in the hierarchy.  The child prefab would have a tk2Dsprite or text mess (happens to both)
3.  Then while nested, make a change to the "child" instance in the hierarch (like changing the position or sprite or color r something)
4.  hit apply on the nested child to write back the changes to the prefab asset

What happens - I have a hard time reproducing this like the original poster is that the mesh filter is set to none.  I then have to recreate the tk2d sprites over again - as the prefab in the above example "child" has the mesh filter corrupted.

anyways, I don't have any nicely reproducible situation  I just think it has something to do with these nested prefabs and making changes to a child prefab (which corrupts the mesh filter).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Possible Bug: Sprites disappearing and mesh filter empty
« Reply #3 on: July 31, 2013, 11:50:32 pm »
This is a bug in Unity :(
It seems to be reproducible without tk2d at all, happens with pretty much any monobehaviour - basically when you have -

Prefab root
    Prefab child

It looks like prefab child may get reset after Awake is called on it. It doesn't have to be modified, I managed to reproduce this without modifying anything at all (prefab root = prefab of an empty game object, and prefab child = prefab of a game object with a really simple script). Its been reported to Unity and they've acknowledged the bug, dunno when it'll get fixed though.

shiraz

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Possible Bug: Sprites disappearing and mesh filter empty
« Reply #4 on: August 01, 2013, 03:55:15 pm »
Ah - well thank you for identifying the issue.

In order to rebuild the lost mesh data, I I wrote an editor script that would call tk2dBaseSprite->Build() on a tk2dSprite - would that restore it?  If so, would be a great editor helper function to "fixup" or check the integrity of all the sprites in a scene - especially to catch situations where the mesh data is lost due to this unity bug (sometimes these are nested down in the hierarchy and really hard to spot until you discover during QA or a play through of the in-game that something is not displaying).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Possible Bug: Sprites disappearing and mesh filter empty
« Reply #5 on: August 01, 2013, 06:40:36 pm »
Thing is, its not just the sprites that are broken in that - if you only had sprites there, you're fine, but if you had any other behaviours on there, they will be broken as well. This is a pretty serious bug actually - it manifests itself visibly here with tk2dSprites, but could be far more disastrous than that if some script silently failed. Its probably best to get rid of situations that cause this.

If you can afford to do it, remove the prefab link from the root object. Eg. if it was a camera, etc. Can I ask how you've got your scene set up?