The issue you're experiencing with the blue tint when swapping SkeletonDataAsset
at runtime on a SkeletonGraphic
component in Unity is likely due to the color properties not being correctly reset or updated during the swap. Here are a few steps you can take to ensure the color properties are correctly applied:
Set the initial skin name and animation: Ensure that you set the initialSkinName
and startingAnimation
properties before initializing the SkeletonGraphic
.
Update the color property: Explicitly set the color property of the SkeletonGraphic
to ensure it doesn't retain any previous tint.
Initialize and set material dirty: Ensure you call Initialize(true)
and SetMaterialDirty()
after setting the new SkeletonDataAsset
.
Here is an updated version of your code with these steps included:
public void SetCharacter(DialogueParser.Characters character)
{
_skeletonGraphic.skeletonDataAsset = Resources.Load<SkeletonDataAsset>($"Characters/{character.ToString()}_SkeletonData");
_skeletonGraphic.initialSkinName = "default"; // Set to your desired skin name
_skeletonGraphic.startingAnimation = "idle"; // Set to your desired starting animation
_skeletonGraphic.Initialize(true);
// Explicitly set the color to ensure no previous tint is applied
var oldColor = _skeletonGraphic.color;
_skeletonGraphic.color = new Color(oldColor.r, oldColor.g, oldColor.b, oldColor.a);
_skeletonGraphic.SetMaterialDirty();
}
Additionally, ensure that the SkeletonGraphic
component is using a compatible shader, such as Spine/SkeletonGraphic Tint Black
, if you are using tinting features.
If the issue persists, you might want to check if there are any leftover properties or settings from the previous SkeletonDataAsset
that could be causing the tint. You can also refer to the Spine Unity Shaders documentation for more details on shader compatibility and settings.