MrShoestore

So, had a Spine skeleton actor in game working fine. My artist re-did the animation (both adding bones and splitting the image up into smaller animation pieces). Went to replace the .json file and update my spritesheet atlas with the new images... the character disappears.

Decided to start from scratch and create a new tk2d Spine Animated Skeleton with my images and json in new folders. still can't get the image to show, and get this error:

NullReferenceException: Object reference not set to an instance of an object
tk2dSpineSkeleton.UpdateSubmeshCache () (at Assets/Spine/spine-tk2d/Code/tk2dSpineSkeleton.cs:166)
tk2dSpineSkeleton.UpdateCache () (at Assets/Spine/spine-tk2d/Code/tk2dSpineSkeleton.cs:152)
tk2dSpineSkeleton.Update () (at Assets/Spine/spine-tk2d/Code/tk2dSpineSkeleton.cs:42)



now, im using 2d Toolkit, Playmaker, and Spine, because I'm not much of a programmer, and none of a coder... So anyone have any quick thoughts as to what might be going on?

thanks,
MrShoestore
  • 記事: 5

Søren

Afraid I can't help you with this one. Nate is back in a couple of days though, maybe he can help out.
Moving the thread to the runtimes section.
アバター
Søren

Shiu
  • 記事: 2396

Duré

I use Unity, tk2d, and Spine.

You make sure to commit your changes to the SpriteCollection?
Are the sprites images that Spine references in the same location that the SpriteCollection references?
Do you only see this error at runtime? If so, do you see the sprite getting drawn in Scene View?
Duré
  • 記事: 42

MrShoestore

@Duré

1. Yes
2. What do you mean by this? How I've understood tk2d spine to work is you import your images into your project and generate a spritesheet(atlas) in tk2d. you then create a spine skeleton data and link up this atlas to the json skeleton file. so Ive been putting the json in a 'skeleton' folder, and images in a 'textures' folder. the image names haven't changed since Spine. Am I missing something with this? the skeleton json doesn't contain image location does it?
3. This error is all the time, so i do not see the character in scene view at all (asides from the position/rotation/scale widget).


My artist sent me a new character with images and it's own skeleton, so tonight im going to import it, and find out if it is an isolated case with the one character or if it's something wrong with our process.

fyi, we've been following the setup video linked to the runtime
http://www.youtube.com/watch?v=dnQbS9ap-i8

worked well for us first time around...
MrShoestore
  • 記事: 5

Duré

You're correct on point 2. It doesn't use absolute paths but looking at the JSON it uses relative paths to the directory you give your spine project for your images. However I tried to change the image locations in Unity so it didnt match that of hte json file and it still worked. This probably is not your issue.

Not sure why it would stop working. You didn't happen to move the location of 2d toolkit in your project did you? It doesn't work properly in the plugins folder.
Duré
  • 記事: 42

MrShoestore

So far we have 3 animated sprites we are trying to get in game. the first one, mentioned here, the skeleton was updated to see if we could solve it. when I replaced the json file in the spine skeleton data, i didn't get the "add mix" button, so there must be an error with that.

the 2nd sprite works fine. he's in, animating, running across the screen... all good.

The 3rd... it imported and i can add as a gameobject in game, but the scale and position of the art textures are all wrong.



when it should look more like this





is there a size limit to a spine animated skeleton? I have to use a 4096 atlas sheet for that guy. I don't know if that is unity stretch and squashing the textures to fit a certain sized area, or if it is an issue in the json file.
We are going to keep pecking at it tonight to find out our problems, but for the first guy (Mr. No-Show) we are thinking it is an issue with how the skeleton is built or saved.
MrShoestore
  • 記事: 5

Duré

Coincidentally, I ran into this same error you've been seeing - the one where you get the NULL reference exception. The problem was I had a slot that had no attachment. It's a bug in the tk2dSpineSkeleton code at the following lines:
Attachment attachment = skeleton.DrawOrder[i].Attachment;
Material currentMaterial = skeletonDataAsset.spritesData.GetSpriteDefinition(attachment.Name).material;
The first line gets the attachment from the slot, which returns NULL. Then on the next line it tries to call the Name member on the attachment and bam, error.

You can fix this problem in one of two ways:

1. In the spine editor by looking for any slots with no attachments and then deleting them.
2. You can fix it in the tk2dSpineSkeleton.cs file by inserting the following check after you get the attachment,
Attachment attachment = skeleton.DrawOrder[i].Attachment;
if(attachment != null)
{
Material currentMaterial = skeletonDataAsset.spritesData.GetSpriteDefinition(attachment.Name).material;
....to the end of the for block
}
I would update the code myself in the repo, but I don't think I have permission to change it.

For the issue with your 3rd sprite, I'm not sure on that one :). It's all on a single atlas right? Even if it wasn't, I think multi atlas support was added recently for spine tk2d runtime so it should work regardless.

Edit: Also, did you disable trimming in the SpriteCollection settings? I'm assuming yes, but if you enable trimming then the sprites will be drawn in the wrong locations on your spine character.
Duré
  • 記事: 42

MrShoestore

disable trimming... that was it! totally overlooked that. Thank You!

now that null error, that sounds like that possibly could have been what was wrong. unfortunately we dorked around with the skeleton in Spine too much and we're having different issues :drunk: :bang:

thankfully the weekend is here and I'll be able to give it a proper look.


EDIT:
Got our Spine stuff sorted, then I added your bit of code to the tk2dspineskeleton and everything is working! Mega-Thanks!
MrShoestore
  • 記事: 5

Nate

Fixed the NPE in git, thanks!
アバター
Nate

Nate
  • 記事: 9730


Return to Runtimes