Using the Sprite Resolver to swap sprites during runtime

Hey there!
I’m currently learning Unity and diving into the first 2D adventures. In my current 2d project, I want to have a simple character where its “Upper Body” can be swapped to create different looking npc’s in one Prefab.

For this purpose, I’ve installed the 2D Animation package and set up my character as described in the docs.

The swapping works perfectly using the visual editor, but I want to change it using a C# script, but I can’t find a way to access the “Sprite Resolver” component. VS cannot find any Component Type called “SpriteResolver” or similar. I couldn’t find a package to import (use UnityEngine.XXX) either.

Could someone please help me out here?
Thank you!

In Visual Studio if you type SpriteResolver and press Ctrl + . (dot) it should pop up suggestions for the namespace that type might be in because it clearly is a C# script so it has to be somewhere.

Otherwise you could try GetComponents() to get all components on the object then log the GetType().FullName of each of them.

currently the namespace is:

using UnityEngine.Experimental.U2D.Animation;

as you can read in the unity documentation. So maybe sth like this may work (untested)

public SpriteResolver mySpriteResolver;

mySpriteResolver.SetCategoryAndLabel(String, String);
mySpriteResolver.ResolveSpriteToSpriteRenderer();