2D Toolkit Forum

2D Toolkit => Support => Topic started by: arvz on April 26, 2014, 04:38:24 pm

Title: Sprites keep disappearing in edit mode, reappears after recommit
Post by: arvz on April 26, 2014, 04:38:24 pm
Hello,

Some of my tk2dsprites constantly stop being rendered in edit mode after pressing stop during play mode in the editor - though they are still there - you can still click on it, and the collider borders appear, but the sprites are invisible. They do appear in play mode, and will reappear if I recommit the sprite collection - but they disappear again after I finish running the game.

This seems to only happen to a couple of sprites, there are other sprites in the scene from the same sprite collection that is not problematic at all.

Edit: I seem to have fixed it by deleting the sprites and readding them again, but I feel like it could happen again in the future

Any ideas what it could be?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on April 26, 2014, 07:43:08 pm
It shouldn't do this. This only happens when something has broken with the collection.
If it ever happens again, please post a repro case so I can work out why its happening.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: fsadeq on July 02, 2014, 07:01:14 pm
Posted in the other thread, but gonna post here as well. This happens to me also. Some sprites, re-adding them temporarily fixes it. Seems to be because of the prefab it's connected to.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: 2dddd on July 24, 2014, 07:38:41 pm
The same thing keeps happening to me. I noticed that when the sprite will not show in edit mode, the Mesh Filter component in the Inspector shows "Missing (Mesh)" for the Mesh drag-and-drop box. But when the sprite appears again, the drag-and-drop box shows a symbol for the mesh as it should. I don't know why it would be doing this seemingly randomly. I'm using a Mac by the way.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on July 25, 2014, 06:44:46 pm
Can you create a prepro for this? The last time I saw a repro for this, Unity was being very naughty and overriding values on the sprite from the prefab AFTER OnEnable / Awake / Start were called. Unity seems to get into this state, its not reproducible on normal projects - I'd be interested in finding out why it happens.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: robertwahler on July 29, 2014, 11:10:17 pm
This is happening to me too. I just updated to Unity 4.5.2, it doesn't happen in Unity 4.3.  I'm going to have to roll back to Unity 4.3 because some sprites are missing and the "Mesh Filter" says "None" only on the missing sprites. If I change any sprite property, the sprite shows up again until I press the run button.  Pressing the run button make the sprites disappear again.

Everything works fine if I create a standalone build. The problem only shows up in the editor.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on July 30, 2014, 12:28:41 pm
This is really annoying, it looks like they may have changed how prefabs work again :(  I can't reproduce this specific issue though, can you create a repro?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: mangoocean on August 02, 2014, 03:47:29 pm
+1 here too. Only started happening since the update
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on August 03, 2014, 12:19:05 pm
Please post a repro for this.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: wtrebella on August 07, 2014, 05:13:19 am
Hey so I was having the same exact problem and I finally figured out how to repro it. I just tried it multiple times, exactly as written below, and it worked every time.

Unity 4.5.2f1 (pro)
2D Toolkit 2.4.0
Mac OSX 10.9.3
2013 27" iMac


Please let me know if you're able to repro!
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on August 10, 2014, 12:47:17 pm
Sorry, I can't reproduce this issue following the steps above - almost identical specs, apart from I'm running on a 2013 Macbook Pro. can you zip up the project and send it my way when its broken?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: wtrebella on August 19, 2014, 04:15:15 pm
Oops, didn't see that you had responded, sorry. Yeah here you go. [removed link]
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on August 20, 2014, 12:35:14 pm
So in this example, it draws the sprite when you've pressed play but is invisible in the editor?
This is because of that change to the prefab system I mentioned before. I can add a "rebuild all sprites" button in Unity to have them draw in scene view, if that will help?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: wtrebella on August 20, 2014, 03:18:48 pm
A "rebuild all sprites" button would be great. Ideally, the way prefabs are handled would be fixed, but I understand that may not be possible. A button to rebuild sprites would be a wonderful temporary solution. Thanks!
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: Callabrator on October 27, 2014, 06:53:32 am
I just wanted to add that I'm seeing, what I think is, exactly the same problem after upgrading from Unity 4.3 to 4.5.4.  The Mesh Filter and the Material get set to "None" on random sprites in my scene.  Playing the scene in the editor sometimes makes those reappear, but also often breaks others.  The sprites all appear to be fine when running on an iPhone.

Has there been any movement on this issue?  Did the "Rebuild All Sprites" button make it into any 2dtk 2.5.x beta release?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on October 28, 2014, 05:24:49 pm
Sorry no, I totally forgot to add it to the trello which I have now.
Add this to tk2dEditorUtility.cs to add the menu option

Code: [Select]

        [MenuItem(tk2dMenu.root + "Rebuild All Sprites", false, 10280)]
static void RebuildAllSprites() {
tk2dBaseSprite[] allSprites = Object.FindObjectsOfType(typeof(tk2dBaseSprite)) as tk2dBaseSprite[];
tk2dTextMesh[] allTextMeshes = Object.FindObjectsOfType(typeof(tk2dTextMesh)) as tk2dTextMesh[];
tk2dStaticSpriteBatcher[] allBatchers = Object.FindObjectsOfType(typeof(tk2dStaticSpriteBatcher)) as tk2dStaticSpriteBatcher[];
foreach (var t in allSprites) { t.ForceBuild(); }
foreach (var t in allTextMeshes) { t.ForceBuild(); }
foreach (var t in allBatchers) { t.ForceBuild(); }
}

Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: Callabrator on November 03, 2014, 02:36:22 pm
Much thanks for that menu fix!

Are there any plans to make a "proper" fix, that won't require using this menu tool?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on November 03, 2014, 11:53:20 pm
Hi,

This doesn't happen for everyone, its because of what Unity have changed in their prefab system. Not sure if its a bug or not, to be honest.
In any case, I can think of a few workarounds to this, but I'd rather not implement them in the event Unity fixes it or reverts behaviour. Just waiting to see what happens in the next version.
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: NoradZero on January 14, 2015, 11:43:58 pm
Im facing this issue on 4.6.0f1 after upgraded to FullInspector 2.5. I use the Rebuild sprites and it work but i have to do it each time i getting back in the scene from play mode. (Back in EditMode)

Probably nothing to do with FullInspector 2.5 but when i upgraded it look like to have triggered something in Unity which make prefab revert to MeshFilter = None each time which is rather strange.

Any ideas to fix this ? Any possible workarounds ?
Title: Re: Sprites keep disappearing in edit mode, reappears after recommit
Post by: unikronsoftware on January 15, 2015, 10:31:32 am
Try this - http://2dtoolkit.com/forum/index.php/topic,4744.0.html