2D Toolkit Forum

2D Toolkit => Support => Topic started by: Moran on March 24, 2013, 12:47:51 pm

Title: Constantly "Rebuilding Index" - Probably VC related
Post by: Moran on March 24, 2013, 12:47:51 pm
Hi!

I SVN "Checked out" a project which had a prefab with sprites in it.
Initially it worked well, but then I changed the prefab and undid the change, if I remember right (didn't pay attention).

The result being that for some objects in the prefab, whenever they are clicked or scrolled to, "Rebuilding Index" always appears several times, even if I click away and immediately back to the same object.

I tried Updating again but erasing the -tk2d file as instructed in some post, not helping.

Help?

EDIT: It also results in this error message, after almost every "rebuild": MissingReferenceException: The object of type 'tk2dIndex' has been destroyed but you are still trying to access it.
Your script should either check if it is null or you should not destroy the object.
tk2dEditorUtility.CreateIndex () (at Assets/TK2DROOT/tk2d/Editor/tk2dEditorUtility.cs:215)
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on March 24, 2013, 08:30:34 pm
Did you update to Unity 4.1 at around the same time?
If you did, you will at least need to be on version 1.91 + patch1. This fixes the "tk2dIndex" issue.

You do have .meta files turned on for svn, right?
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: Moran on March 25, 2013, 07:18:04 am
I did update Unity. Since I bought td2k under another account, my package don't auto-update. I'll update and report, although I already rebuilt the entire object and that also worked.

We've been using SVN for a while, "meta files" is selected and we're using "force text".
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on March 25, 2013, 01:09:53 pm
OK. Let me know how it goes and we'll take it from there.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: netlander on April 16, 2013, 07:43:30 am
Hi,
I am having the same problem as above. When I check out from svn (standard setup) I get index out of range and all animations are gone haywire. Is there a simple way of avoiding this?

Unity 4.0 ~ tk2d 1.9
Thanks
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 16, 2013, 11:41:49 am
Meta files are on, right?

Also, what happens if immediately after you get latest from svn, you restart Unity, and then rebuild index?
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: netlander on April 16, 2013, 04:18:54 pm
After posting this I tried checking out again and since by chance I had added the -tk2d file, I checked it out with the rest of the source and the whole thing worked.

Didn't build indexes, just ran the project and things were in better shape.

Not sure if this is pure luck or the fact that I had the original -tk2d file with the project in svn helped mitigate the problem.

What are your recommendations regarding using version control with the toolkit, should we add the -tk2d file or any others?

And yes .meta and force text on.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 16, 2013, 05:03:18 pm
The -tk2d file shouldn't be checked in, it could cause issues when merging changes, but shouldn't be an issue if you're using text serialization. The best practice should be to rebuild index manually after updating from VC.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: netlander on April 16, 2013, 05:25:55 pm
Rebuilding indexes and -tk2d file was the cause of my loosing the animations, the alternative was to go and rebuild all anims manually and relink them to the animated sprites in my levels (hours of work potentially).

In the case where you recommend index rebuild after checkout, why do you think the animation settings are getting corrupted? worth noting that not all animations are affected.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 16, 2013, 05:38:34 pm
I'm not sure to be honest - It is probably best to look at the contents of the .prefab in a text editor to debug that. There are references to sprite collection data objects in there, and if they are somehow different when checked out then that is one reason it could possibly corrupt the animation. The other option is to look at the broken animation immediately in debug inspector mode to see if all references are correct?

If you do find out what it is, please let me know so I can address it properly.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: Moran on April 17, 2013, 07:28:19 am
Forgot to update but the patch for 1.90 and the following version solved the issue for me.

Now, after a merge, whether -tk2d is versioned or not, clicking on "new" sprites causes the index to be rebuilt just once and that's it.

Thanks and good luck netlander.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 17, 2013, 09:35:06 am
@Moran - that was an issue specific to Unity 4.1 & tk2d 1.90/91 without the patch. Unity decided to change how something worked without any warning and that broke index generation :( Is this the case in yours @netlander?
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: netlander on April 17, 2013, 11:05:31 am
Nop, I'm still on 1.9.0/Unity 4.0 but I think it's a quirk in these versions, I've gone through the process of checking out and rebuilding, this time I didn't encounter the problem.

My solution was to proceed as follows:

Check out the project.
Import tk2d.
Run (so the index is rebuilt).

This seemed to have avoided me having corrupt animations but I can't say for certain what's exactly happening.

Thanks for your help guys.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: aegzorz on April 17, 2013, 02:38:00 pm
I think I'm having the same issue, Unity keeps running "Rebuilding Index" and collections that are loaded through tk2dSystem.LoadResourceByName stops working. I wouldn't mind it so much if rebuilding the index was reasonably fast but it takes approximately 5 minutes to rebuild the index in our project :/

Is there a log somewhere that I can check to see what is actually breaking the collections?

Edit: I'm using tk2d 1.92 + patch and Unity 4.1
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: aegzorz on April 17, 2013, 03:19:52 pm
Ok, I've narrowed down the problem to the following scenario:

- Run the game
- Select a gameobject with a runtime loaded sprite collection in the Hierarchy view
- Unity starts rebuilding the index over and over

This is making it impossible to inspect the objects we're using.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 17, 2013, 03:29:12 pm
How is this loaded at runtime? Just tk2dSystem? Or is this specific case loaded by any other means?
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: aegzorz on April 17, 2013, 03:55:43 pm
It is loaded through tk2dSystem yes, like this:

tk2dSpriteCollectionData collection = tk2dSystem.LoadResourceByName<tk2dSpriteCollectionData>( collectionName );

Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on April 18, 2013, 09:42:11 am
I'll investigate that.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: hitorijanai on June 04, 2013, 08:57:48 am
So do you have a workaround for this? I'm having the same problem like Aegzorz has said..
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on June 04, 2013, 09:52:57 am
This should be fixed in tk2d 2.0. What version are you working on?
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: BTriana on July 18, 2013, 05:42:17 pm
This should be fixed in tk2d 2.0. What version are you working on?

I am currently using tk2d 2.0 and I am experiencing the same problems mentioned in this post.

Just to restate:

-Clicking on some elements with a tk2dsprite in the inspector (both at runtime and not) causes Unity to enter a frozen state.  A popup appears saying "Rebuilding Index" with a progress bar that runs indefinitely.  I haven’t fully isolated why it’s only some of the tk2dsprites that cause this, but I will post an update when I do.

I have attempted to manually rebuild my indices through the 2D Toolkit panel in Unity, but this doesn’t change the behavior I mentioned above.

tk2d is a great piece of software, but this particular issue is a huge block to my current work flow.  Debug printing transform values for tk2d elements is too slow to implement my tasks (GUI).
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on July 18, 2013, 05:56:06 pm
We've improved the code yet again in 2.1 - when it does this it usually meant it couldn't find something it expected to find in the project. I.e. it rebuilds the index expecting to find something in the next interation, but then it doesn't for some reason or other and goes into this infinite loop. I've changed the behaviour so it fails a bit more elegantly, i.e. simply displays a "-" when it can't find something after one attempt at rebuilding the index.

If you can create a repro case, I can almost certainly fix it for you. I've found more than one case of random weirdness so far.

I don't understand this bit: "Debug printing transform values for tk2d elements is too slow to implement my tasks (GUI).".
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: Goepfie on July 19, 2013, 03:18:00 pm
Had a similar Problem today.

Using SVN with several Coders. One Working Copy changed the *.meta of a series of Sprite Collections (Don't know why). Turns out, for some reason all guid's in there have been changed. I triggered a rebuild to correct the mess and it seemed to work, but if you now selected any sprite and tried to change the SpriteCollection the Rebuilding Index Loop occurred. Only solution was to revert the to original Meta-Files.

We are using 2.1 beta 2. Sadly I can not provide you with an repro-project, because it currently exceeds 2 Gigabyte and contains sensitive data.

Maybe this helps clarifying issues like that.
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: unikronsoftware on July 19, 2013, 06:50:53 pm
What meta files did it change in total? It should NEVER change meta files for any existing assets :( If GUIDs are broken, then this will inevitably break - and theres more stuff broken than just the index....
Title: Re: Constantly "Rebuilding Index" - Probably VC related
Post by: Mozgoid on June 13, 2014, 12:55:01 pm
Hello, may be my problem and it's solution will help somebody.

Situation:
In our game we had levels that full of various objects(sprites) that placed everywere. I have xml file that converted from psd file. This file have names and positions of objects. My task was write a script that reads that file and place right sprites in right positions. All this must be done in editor mode, and created objects will saved as prefab. Important : we defined platform specific sprite collections, for 1x and 2x platforms.

What i done:
Script has reference to tk2dSpriteCollectionData. He read sprite name from xml; find sprite collection that has definition of sprite with readed name; create  a sprite with right collection and name; add it to the scene.
Here structure of folders where placed sprite collections:
US/US_Objects_1_Data/US_Objects_1@1x_Data/US_Objects_1@1x  (generated tk2dSpriteCollectionData)
US/US_Objects_1_Data/US_Objects_1@1x_Data/atlas0
US/US_Objects_1_Data/US_Objects_1@1x_Data/atlas0 material
US/US_Objects_1_Data/US_Objects_1@2x_Data/US_Objects_1@2x  (generated tk2dSpriteCollectionData)
US/US_Objects_1_Data/US_Objects_1@2x_Data/atlas0
US/US_Objects_1_Data/US_Objects_1@2x_Data/atlas0 material

US/US_Objects_1_Data/US_Objects_1  (generated tk2dSpriteCollectionData)
US/US_Objects_1_Data/US_Objects_1@1x (generated tk2dSpriteCollection)
US/US_Objects_1_Data/US_Objects_1@2x (generated tk2dSpriteCollection)

US/US_Objects_1 (tk2dSpriteCollection)


Problem:
My script must have reference to tk2dSpriteCollectionData.
If I give him reference to US/US_Objects_1_Data/US_Objects_1 then it can't find any sprite.
If I give him reference to US/US_Objects_1_Data/US_Objects_1@1x_Data/US_Objects_1@1x , the script generate my map. Map look fine, but infinite "rebuiding index" starts when I select one of objects. Anyway I don't sure is it good to use platform specific data (US_Objects_1@1x) for generation

My solution:
Before generating a map I deleted platform 2x from sprite collections. And my folders became like this:
US/US_Objects_1_Data/US_Objects_1  (generated tk2dSpriteCollectionData)
US/US_Objects_1_Data/atlas0
US/US_Objects_1_Data/atlas0 material
US/US_Objects_1 (tk2dSpriteCollection)

In script I give reference to US/US_Objects_1_Data/US_Objects_1.  And generate map. Everything looks fine now. And now I can select any of generated objects. I save this as prefab. And after that I add platform 2x to sprite collection. As result I get generated map that uses platform specific sprites.

May be all this is very specific, but I hope I help  somebody. Sorry for my English :)