Hello Guest

Author Topic: Can't select Sprite animation  (Read 5890 times)

limegreen

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Can't select Sprite animation
« on: September 12, 2017, 08:09:05 pm »
I am using 2D Toolkit 2.5.6 with Unity 2017.1.1f1.  I am completely new to tk2d, and no great shakes with Unity either, so I may well have done something stupid. 

I have imported a sprite sheet image into a tk2d Sprite Collection, and I can see that it has isolated the individual sprites correctly into their own images.

I have created a Sprite Animation that refers to this collection.  I asked tk2d to fill the clip with the "Autofill 1.9" button, which it did correctly.  I can click the "Play" button and see my sprite animating as I expect in the Sprite Animation editor.

So now I add a sprite with GameObject -> Create Other -> tk2d -> Sprite with Animator.  That lets me select my Sprite Collection, and it then auto-selects the first image as "Sprite", and that image is displayed underneath, exactly as expected.  However, when I try to change the "Anim Lib" in the "Tk 2d Sprite Animator" section, I see my SpriteAnimation in the drop down box, but when I try to select it, it just silently reverts to the default (first) one.  At the same time, I get this error logged in the console:

NullReferenceException: Object reference not set to an instance of an object
tk2dSpriteAnimatorEditor.OnInspectorGUI() (at Assets/TK2DROOT/tk2d/Editor/Sprites/tk2dSpriteAnimatorEditor.cs:91)

The line of code in question is this:

        if (animator.Library.clips.Length > 0)

Can you help me to understand what the problem is, or how I can find out more about what's going on?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can't select Sprite animation
« Reply #1 on: September 12, 2017, 09:23:42 pm »
Hi,

Your 2d toolkit is out of date. Please update to the latest here (http://2dtoolkit.com/forum/index.php/topic,5527.0.html).

Did you download that from the fastspring store? Could you please send the copy you got to my support email address please?
After investigating it looks like the file on fastspring hadn't been updated in a while. Apologies for the inconvenience.

« Last Edit: September 12, 2017, 09:35:37 pm by unikronsoftware »

limegreen

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Can't select Sprite animation
« Reply #2 on: September 13, 2017, 12:57:29 pm »
OK, I have installed the latest package in a new project and I don't see that problem any more.  I'm not sure if the new package fixed it or not, to be honest - by tinkering with new projects and different orders of operation last night, I was able to get it working with the old version, so I don't know if I have just been fortunate that the new version worked first time...

One problem I had with 2.5.6 that is still a problem with 2.5.8.6 is naming of SpriteCollections and SpriteAnimations.  I create a new SpriteCollection and rename it in the Inspector tab to "ThePigCollection" - indeed, if I don't, it won't let me access the editor.  But the name remains "SpriteCollection" wherever it shows in Unity - in the Assets view, in dropdown boxes, even in the Inspector if I click away from the SpriteCollection and then go back to it.  The same is true for SpriteAnimations, except that it does seem to hang onto the new name in the Inspector tab and the Animation Editor until I click "Commit" in the animation editor.  Then it reverts to a name of "SpriteAnimation" in the Inspector and in the animation editor (it has been "SpriteAnimation" elsewhere in Unity all along).

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can't select Sprite animation
« Reply #3 on: September 13, 2017, 10:54:01 pm »
The new package had loads of compatibility fixes for Unity 5.4 and beyond, 2.5.6 was around 1 year old and was released when Unity 5.3 got released.
 

Quote
One problem I had with 2.5.6 that is still a problem with 2.5.8.6 is naming of SpriteCollections and SpriteAnimations.  I create a new SpriteCollection and rename it in the Inspector tab to "ThePigCollection" - indeed, if I don't, it won't let me access the editor.  But the name remains "SpriteCollection" wherever it shows in Unity - in the Assets view, in dropdown boxes, even in the Inspector if I click away from the SpriteCollection and then go back to it.  The same is true for SpriteAnimations, except that it does seem to hang onto the new name in the Inspector tab and the Animation Editor until I click "Commit" in the animation editor.  Then it reverts to a name of "SpriteAnimation" in the Inspector and in the animation editor (it has been "SpriteAnimation" elsewhere in Unity all along).

I'm not sure how to best investigate this - I can create a new sprite collection and rename it. It is expected behaviour that the name in the dropdowns doesn't change until it is committed (the index tk2d uses to cope with large numbers of sprites only gets updated on commit), but it should definitely let you rename it in the inspector at any point.

Can you elaborate on this please? "But the name remains "SpriteCollection" wherever it shows in Unity - in the Assets view, in dropdown boxes, even in the Inspector if I click away from the SpriteCollection and then go back to it."  Once you rename and commit the name should change everywhere (eg. when you create a new tk2d sprite in the scene and select it in collections list)

limegreen

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Can't select Sprite animation
« Reply #4 on: September 21, 2017, 04:07:59 pm »
I was renaming the Sprite Collection in the Inspector panel - in the name field that appears right at the top, regardless of the type of game object you are looking at.  It doesn't seem like there is a way to separately commit when you change things in that panel - you change something, it's changed...?

Anyway, I discovered that if I instead change the name of the Sprite Collection by selecting it in the Project assets view, pressing F2 and then renaming it in-place, that works fine and the name does not revert.  So this is not an issue for me any more

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Can't select Sprite animation
« Reply #5 on: October 04, 2017, 11:35:35 pm »
Hi, this sounds really odd but - Unity consistently lets you change the names of objects in your project (not hierarchy) but will not save this. The name of the object is always pulled from the filename of the asset - so if your SpriteCollection is called SpriteCollectionA in the OS, that will be the name next time unity restarts. The correct way to "rename" an object is rename using F2 like you found.