Hello Guest

Author Topic: Transfer Sprite Collections from PC to MAC results in NullReference error  (Read 13302 times)

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Hi,
 I have my project built and running fine on a PC. I copied the whole project over to a MAC and when I open it - I get hundreds of errors - one for each sprite:

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:909)
tk2dSprite.Awake () (at Assets/TK2DROOT/tk2d/Code/Sprites/tk2dSprite.cs:21)

I found that if I open the sprite collection and rebuild it - it works ok.

Do I have to rebuild all my spritecollections each time I move from the MAC to a PC?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
We use it cross platform all the time with no issues. How are you moving the project? Do you have meta files on / version control? Are you ensuring the libraries folder isn't copied?

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Hi,
  I fixed all the errors on the MAC by opening each sprite collection and re-commiting them. However, when I went back to the PC - I got the same errors.

 The project is moved back and forth via version control - Perforce.

I have Hidden Mete Files selected as my version control mode in the editor settings.

No - the library folder is not copied.

-Mike

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #3 on: February 02, 2015, 12:12:17 am »
Are the meta files being submitted?

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #4 on: February 02, 2015, 03:36:40 pm »
Yes - the meta files are checked-in.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #5 on: February 02, 2015, 04:04:59 pm »
Hmm thats weird, what version of tk2d & unity are you using, and does the issue happen both ways? (do you have issues if you open a mac project on pc?)

we use it cross platform all the time, and I know many others do too. We'll need to figure out why you're having issues, as there shouldn't really be any issues ilke this.

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #6 on: February 02, 2015, 05:36:55 pm »
Yes - it happens both ways.
The first time it happened on the MAC - I saw that all my sprites were missing their Material references, so I opened each Sprite Collection and re-committed it. (Pressed the Commit button).
That fixed all of the problems on the MAC. Then I checked-in all those files and when I synced to the PC and opened the project I got the exact same errors. Opening each Sprite Collection and re-committing once again fixed the problem, but obviously this isn't a viable solution.

My project is set for 2 platforms (1x and 2x). I did notice that in the 2D ToolKit preferences dialog, under platform - nothing was selected, so I selected 1x.

Also as a rule of thumb, when I add a project to Perforce, I add the entire Assets directory. After reading a piece about using 2D Toolkit and version control - I saw that there were many files used by 2D Toolkit, that should NOT be added to version control (i.e. -tk2d.asset, -tk2d.asset.meta and all of the files in the Resources/tk2d directory).

I removed all of these files from version control, deleted the library directory, opened Unity and rebuilt the 2D Toolkit indexes. This was on the PC. Then I checked-in, checked-out on the MAC and did the same - no help. All sprites are missing their material references.

I'm at a loss for what to try next.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #7 on: February 02, 2015, 06:00:41 pm »
Ok... if you have platforms, that narrows it down slightly. Have you tried restarting unity once it is broken?
Can you create a minimal repro case for this? Ideally 1 scene and one simple sprite collection, should be able to track it down if I can get it to consistenly break over here.

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #8 on: February 02, 2015, 08:25:29 pm »
So I copied my project to a separate directory and paired it down to a single scene and 2 sprite collections. Not surprisingly, after doing this the problem disappeared.

I don't know if this helps - but when I initially started the project, I had no platforms. It wasn't until later on that I started using multiple resolution textures. At that point I turned on platform support (1x,2x) for each of the sprite collections.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #9 on: February 02, 2015, 11:08:19 pm »
Does just copying it into a separate directory make a difference? Before you delete stuff.

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #10 on: February 04, 2015, 05:49:35 pm »
Yes - strangely it does. I copied it locally to a shared location on my pc and then from there to the MAC and it works.

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #11 on: February 05, 2015, 01:51:42 am »
Copying the project directory over to a MAC works fine - checking it to Perforce and then Checking it out on the MAC breaks all of the Material references in all the sprites. It appears that Perforce is doing something to the files.

I have my Serialization Mode set to "Force Text" - this leads me to believe "Line Endings" in the text files may be the culprit.

Have you transitioned from MAC->PC using a version control system?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #12 on: February 05, 2015, 04:30:32 pm »
Yes, we do it on a daily basis, the 2D Toolkit repo itself is in svm - we use PlasticSCM. I haven't used perforce with unity though.

mterlecki

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #13 on: February 05, 2015, 09:57:42 pm »
Do you have any other suggestions on how to correct this issue?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Transfer Sprite Collections from PC to MAC results in NullReference error
« Reply #14 on: February 05, 2015, 10:48:00 pm »
I don't know what the the problem - if its due to line endings, then there must be something in the version control system to normalise that? Either that or not everything that is needed is version controlled. You could do a diff between the 2 folders to see any diff between a working and broken project.