Unity 2D Animation won't compile in VisualStudio, but will in Unity

I have a project using Unity’s 2D Animation package, which runs fine within Unity, but when i try to build the project within VisualStudio i get this error:

.../Assets/Samples/2D Animation/3.2.3/Samples/5 SpriteSwap/Scripts/Editor/BuildAssetBundle.cs(17,17): Error CS0103: The name 'LoadSwapDLC' does not exist in the current context (CS0103) (Unity.2D.Animation.Samples.Editor)

Here’s a screenshot of the error in context:

I’ve just started working on this project again after a few months break, so perhaps could be related to upgrading my unity version.

I’ve tried removing the 2D Animation packcage and re-installing, but no luck.

2D Animation version 5.0.7.

Thanks for the help!

Oh i think i worked it out! natrually after spending 2 hours tyring to work this out, I fixed it 2 mins after posting this question!! I want to leave it up in case anyone else comes across it.

I noticed that the error message i pasted above mentions /Samples/2D Animation/3.2.3/Samples/, which is a different version to my 2D Animation package (5.0.7).

Sure enough, if you go into Package manager and select 2D Animation, there’s a little “Samples” option you can expand which allows you to update or re-install the samples. I did that and now it works!

HEre’s a screenshot so you know where to look (see Samples option, then under there will be UPdate or Re-Import. click that!)

1 Like

I’m happy that you managed to solve your issue, and thank you for sharing the solution as well!