• RuntimesUnity
  • SkeletonDataAsset swap in runtime has blue tint

I'm trying to swap SkeletonDataAsset on SkeletonGraphic (Unity UI Canvas) in runtime. And my result has blue tint. If I reload the Asset the result is correct.

public void SetCharacter(DialogueParser.Characters character)
{
_skeletonGraphic.skeletonDataAsset = Resources.Load<SkeletonDataAsset>($"Characters/{character.ToString()}_SkeletonData");
_skeletonGraphic.Initialize(true);
_skeletonGraphic.SetMaterialDirty();
SpineEditorUtilities.ReloadSkeletonDataAssetAndComponent(_skeletonGraphic);
SpineEditorUtilities.ReinitializeComponent(_skeletonGraphic);
}

Blue tint:

After Reload button pressed:

Related Discussions
...

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:

  1. Set the initial skin name and animation: Ensure that you set the initialSkinName and startingAnimation properties before initializing the SkeletonGraphic.

  2. Update the color property: Explicitly set the color property of the SkeletonGraphic to ensure it doesn't retain any previous tint.

  3. 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.

Tried the suggestion by Spinebot and nothing changed. Result is still tinted blue even though the Skeleton Color is white.

@Zarezy In general note that you can't use SpineEditorUtilities methods like ReloadSkeletonDataAssetAndComponent in your actual runtime game code, as with any editor code. I assume that you wanted to use them for this test only.

Could you perhaps send us a minimal Unity project which still shows this issue? You can send it as a zip file to contact@esotericsoftware.com, briefly mentioning this forum thread URL so that we know the context. Then we can have a look at what's going wrong.