2D Toolkit Forum

2D Toolkit => Support => Topic started by: vicenterusso on April 15, 2014, 01:47:41 pm

Title: 2D Toolkit and Git
Post by: vicenterusso on April 15, 2014, 01:47:41 pm
Everytime I pull my project from another machine, I need to re-commit every sprite collection. Heres what happen:

Code: [Select]
NullReferenceException: Object reference not set to an instance of an object
tk2dSpriteCollectionData.get_inst () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteCollectionData.cs:555)
tk2dBaseSprite.Awake () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dBaseSprite.cs:901)
tk2dTiledSprite.Awake () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dTiledSprite.cs:87)

And here is my .gitignore about 2dtk:

Code: [Select]
Assets/-tk2d*
Assets/Resources/tk2d.meta
Assets/Resources/tk2d/*

Read it somewhere and started using. Anyway, whats is the necessary files to avoid this error?
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 15, 2014, 05:01:26 pm
Do you have meta files turned on and are you checking in all the meta files for everything?

After you import on the new machine you should 2D Toolkit > Rebuild.
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 15, 2014, 05:45:27 pm
Do you have meta files turned on and are you checking in all the meta files for everything?

After you import on the new machine you should 2D Toolkit > Rebuild.

Meta files turned on and included for everything. Rebuild Index didn`t worked. Tried before...
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 16, 2014, 10:21:02 am
Most people, including us use some form of version control (we use Hg and Plastic) with meta files with no problem. Are you getting this issue consistently, and are you checking in the libraries folder as well?
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 16, 2014, 01:50:32 pm
My Libraries folder is not included. Here is my .gitignore:

http://hastebin.com/nuxevocawe.pl

And my generic .gitattributes file:

http://hastebin.com/resejemabo.mel

Edit: yes, I do have this problem every time..
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 17, 2014, 02:58:15 am
Not sure what to suggest here. This is not a known problem. The only thing I can think of is to look at the project, should be sufficient even if you can isolate it to 1 sprite collection thats broken.
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 20, 2014, 01:29:58 am
Not sure what to suggest here. This is not a known problem. The only thing I can think of is to look at the project, should be sufficient even if you can isolate it to 1 sprite collection thats broken.

Almost sure it won't help, but anyway.. the error when I open a project in another machine:

Quote
NullReferenceException: Object reference not set to an instance of an object
tk2dSpriteCollectionData.get_inst () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSpriteCollectionData.cs:555)
tk2dBaseSprite.Awake () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dBaseSprite.cs:901)
tk2dTiledSprite.Awake () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dTiledSprite.cs:87)
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 20, 2014, 10:34:22 am
That implies that it hasn't successfully loaded some platform specific sprite collection. Try deleting the  Resources/tk2dFolder, -tk2d object and then 2D Toolkit > Rebuild Index. That may help, if it doesn't it does imply something is breaking, but its close to impossible to work out what without looking at a broken dataset.

Note - if you're using text serialisation make sure git is merging correctly.
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 20, 2014, 05:21:41 pm
The Resources folder is not on my git project. When I change machine, the Resources/ files are not changed. Maybe thats the problem? I will add these files to git project and see what happens...

My .gitignore:
Code: [Select]
Assets/-tk2d*
Assets/Resources/tk2d.meta
Assets/Resources/tk2d/*
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 22, 2014, 02:31:40 pm
Resources/tk2d.meta should be regenerated, but the other files should be there. Let me know how it goes. Not sure how I overlooked that in the first post...
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 22, 2014, 03:25:40 pm
Resources/tk2d.meta should be regenerated, but the other files should be there. Let me know how it goes. Not sure how I overlooked that in the first post...

What do you mean by regenerated? From what I understood you`re telling me to keep Resources/tk2d.meta out of source control? It`s already on my git ignore... so it`s suppose to regenerated everytime. Maybe, it`s related to this issue ( http://2dtoolkit.com/forum/index.php/topic,3989.0.html )?
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on April 23, 2014, 11:12:36 am
I should have been clearer.
Resources/tk2d.meta and Resources/tk2d/* should not be in the ignore file and should be checked in.
In theory, rebuilding the index should regenerate these, but I've not tested that since the feature was first implemented ages ago, so that may be what is causing your problem.

Try removing this from the ignores, and check these in, see if it works better.
Assets/-tk2d* is the only tk2d related thing that should be in the ignores.
Title: Re: 2D Toolkit and Git
Post by: vicenterusso on April 23, 2014, 03:26:26 pm
I should have been clearer.
Resources/tk2d.meta and Resources/tk2d/* should not be in the ignore file and should be checked in.
In theory, rebuilding the index should regenerate these, but I've not tested that since the feature was first implemented ages ago, so that may be what is causing your problem.

Try removing this from the ignores, and check these in, see if it works better.
Assets/-tk2d* is the only tk2d related thing that should be in the ignores.

I re-tested.

Checking out on another machine, rebuilding index, closing unity and reopen again, fixes the problem. But I`ll leave only on Git Assets/-tk2d*

Title: Re: 2D Toolkit and Git
Post by: piscopo on December 13, 2017, 07:34:43 pm
I should have been clearer.
Resources/tk2d.meta and Resources/tk2d/* should not be in the ignore file and should be checked in.
In theory, rebuilding the index should regenerate these, but I've not tested that since the feature was first implemented ages ago, so that may be what is causing your problem.

Try removing this from the ignores, and check these in, see if it works better.
Assets/-tk2d* is the only tk2d related thing that should be in the ignores.

Sorry for reviving an old post, but I just need something clarified. Is the above the most up-to-date rule in regards to handling 2D Toolkit in Git? For the past several projects we've been following what it says in the Manual on the 2D Toolkit website (http://2dtoolkit.com/docs/latest/advanced/version_control.html), so we've been excluding the Resources/tk2d/*. After coming across this post I'm now questioning the way we've been doing it this whole time. Is the Manual out of date as far as version control is considered?

Also, in the "After updating..." section of the Manual, is that referring to after updating the version of the 2D Toolkit asset, or after pulling any changes related to sprite collections, animations, etc.?
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on December 14, 2017, 09:52:37 pm
Hi,

Yes thats correct. The manual was never updated from the looks of it, sorry its fixed now. Resources/tk2d/* can be reconstructed but it should be checked in.

> Also, in the "After updating..." section of the Manual, is that referring to after updating the version of the 2D Toolkit asset, or after pulling any changes related to sprite collections, animations, etc.?
After updating refers to pull / merge (in git parlance) or or otherwise changing any sprite collection assets externally from unity.
Title: Re: 2D Toolkit and Git
Post by: piscopo on January 02, 2018, 05:46:21 pm
Thank you for the clarification. :)
Title: Re: 2D Toolkit and Git
Post by: danmerey on January 08, 2018, 04:32:33 pm
So you say I should "Rebuild Index" every time I push something related to tk2d?

What should I do if I need to auto-build my project (for example I use Unity Cloud Build for fast iOS builds)? I get a lot of "broken builds" sometimes and can't do anything with it (some atlases just corrupted, sprites a sliced and messed up).

Can this "Rebuild Index" happen by itself without manual pressing button? Or at least every time before build or something like that?
Title: Re: 2D Toolkit and Git
Post by: unikronsoftware on January 17, 2018, 10:38:59 pm
Hi,

It should pick up and rebuild the index when it detects changes - but I have seen this fail occasionally due to dates not propagating thru, etc. In this case however, you could try making it Rebuild automatically. For example, just before a build is started...

Code: [Select]
using UnityEditor;
using UnityEditor.Build;
using UnityEngine;

class tk2dRebuildIndexPreprocessor : IPreprocessBuild
{
    public int callbackOrder { get { return 0; } }
    public void OnPreprocessBuild(BuildTarget target, string path)
    {
          tk2dEditorUtility.RebuildIndex();
    }
}