Hello Guest

Author Topic: fix missing texture on sprite collection  (Read 8636 times)

fremachuca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
fix missing texture on sprite collection
« on: January 27, 2014, 04:19:40 pm »
hello there.

i have a 4k x 4k sprite collection with 30+ textures and some dicing. had to move my unity project between 2 computers and reorganize some folders.
now 6 of the textures appear as missing from the sprite collection editor. these textures are still exactly the same as they where, they are simply now in a different folder and have a different name.
i went and clicked on each of the missing textures, and reasigned the textures(through the colletion editor). sweet. everything should work now. but since its a huge atlas it keeps going for minutes after i commit and crashing unity at some point. i can try committing it in a better computer or something, its fine.

but my question is:
shouldnt this be simpler? since the texture is exactly the same as it was before, why does it need to "commit"? it just needs to know where that same texture is now. maybe a save button beside the commit, to make changes that actually dont need to reorganize the atlas, create a new atlas texture or go through crazy mathematical equations that take minutes?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: fix missing texture on sprite collection
« Reply #1 on: January 27, 2014, 04:34:41 pm »
How did you transfer it between computers? Did you have meta files turned on?

fremachuca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: fix missing texture on sprite collection
« Reply #2 on: January 27, 2014, 05:21:17 pm »
im not sure now. i think meta files where on. and the transfer between the computers was made by copy paste.
but i did change the name of the files and moved them to another folder (all this done on finder, not inside unity)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: fix missing texture on sprite collection
« Reply #3 on: January 27, 2014, 05:24:26 pm »
If you changed the name of the files, but you didn't change the corresponding meta files (they are hidden by default in Unity 4.3), it would lose references to them....

fremachuca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: fix missing texture on sprite collection
« Reply #4 on: January 27, 2014, 05:38:31 pm »
yes, i know. im not blaming 2dtoolkit for that.
im just asking whats the easiest way to fix this, if and when something like this happens.
if i updated the meta file with the new directory and file name would 2dtoolkit automatically find the "missing" texture?

fremachuca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: fix missing texture on sprite collection
« Reply #5 on: January 27, 2014, 06:23:22 pm »
ok. let me make things simpler.
i have 2 folders. folder1 and folder2.
all my textures are inside folder1 and i create the atlas there.

for some unknown reason from the universe some of the textures are moved from folder1 to folder2 (in finder, internet explorer whatever)
this makes the colletion editor tell these files are missing. OK.

moving the textures back to folder1 makes them work again, but for some reason, i NEED them to be in in folder2. so thats out of the question.

opening the sprite collection editor and reselecting the textures on their new location works. but i could have have 20 atlases in my project that take 3 minutes each to commit. 1 hour just to wait commits is too much.

here comes the thing. i just need to tell 2dtoolkit the new location of these textures. the texture files havent changed in any way (size or color) so i dont need 2dtoolkit to recommit, creating a new atlas texture file.

so. is there a faster easier way of "reconnecting" these textures to 2dtoolkit?! without having to wait long commit times?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: fix missing texture on sprite collection
« Reply #6 on: January 28, 2014, 10:33:46 am »
Why not move the files from within Unity? Wouldn't that just work?

Another option is to not bother copying the source textures - just the data folder is sufficient if you just want to use the atlas. Once you copy, you will need to run 2D Toolkit > Rebuild Index, but thats about it.

fremachuca

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: fix missing texture on sprite collection
« Reply #7 on: January 28, 2014, 11:14:05 am »
moving the files from inside unity would definitely work. but im here in the forums asking this because the damage has already been done.
and even knowing that its just a matter of moving the files from inside unity, i believe this might happen again at some point. with more people working on the project, 20+ folders with 40+ textures in each, s#*t can happen after 3 months of work.

since my project has lots and lots of 4k atlases, and the commits are taking minutes, i was wondering if there was a simple way of reconnecting the "missing" textures.
something like a "reconnect textures/find textures" in the menu where it would search the whole project for these "missing" texture by name, and reconnect them.

i know i can use only the atlas. but i would rather do this at the end of the project, not in the middle while textures might still change.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: fix missing texture on sprite collection
« Reply #8 on: January 28, 2014, 11:34:13 am »
tk2d uses the asset references (GUIDs) to store references to textures. There is no reference to the filename / path anywhere in the system. There is no way to reconnect textures that have been disconnected without knowledge of how you set it up. You can certainly write something to wire stuff up if you know where to look for textures and you know that they haven't been renamed.

If your concern is the long time to commit the atlas - You also don't need to Commit after reconnecting the textures, you can simply comment out tk2dSpriteCollectionBuilder.Rebuild in tk2dSpriteCollectionEditorPopup.Commit() temporarily while you fix up the collections and that will just save the settings & not rebuild the collection.

Unity isn't going to break connections if you move / rename stuff from within Unity - it will update the library appropriately. What you're doing is not recommended when working in Unity (for anything, not just tk2d), it carries a high risk of screwing up the metadata.

pheu

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: fix missing texture on sprite collection
« Reply #9 on: August 07, 2014, 09:19:45 am »
I'm having this issue sometimes even though I don't change textures or move them anywhere. For example when working with somebody else with SVN, but I can't state the exact reason, it might be caused by metadata change.