• Bugs
  • Setting Color on attachment doesn't work (Unity + tk2d)

Created two skins, one of which is a copy of the other but has a couple of parts colored 100% black. Setting the Skin in Unity seems to have no effect


both skins show up exactly the same. I have tried both of the Spine shaders, no luck so far.

To clarify, I am coloring the attachment by selecting the image in Spine Setup Mode:

I can see the color associated with this skin in the .json file, so I know it's getting exported properly, it just seems that the Spine rendering code is ignoring the data. That's my best guess anyway!

Any thoughts? Thanks!

David

Related Discussions
...

Strange.
I don't think Spine-C# supports region colors yet though. The RegionAttachment class doesn't have fields for color channels yet. It's not rendering it because the runtimes don't read and store that data at runtime yet.

This means the problem is specific to using colors on specific images/region. I didn't even realize this was a feature in the editor already.

Spine-Unity's coloring otherwise works fine. You can set and animate slot colors and it should work (This is for other purposes, I guess. Slot coloring isn't going to work for coloring specific skins.).

5 dias depois

Yes, per attachment color is a recent feature and hasn't been implemented in most runtimes yet, sorry. It allows attachments in skins to have different colors.

The "path" field for region attachments (also not in runtimes) is related, which allows the same image to be in a slot twice (same path, different name). This allows the same attachment to be in a slot multiple times, with different colors or offset SRT. This is needed for meshes, which you may want in a slot multiple times with a different deformation.

Until it's implemented you can do it with code...

Color blackTint = new Color(0f,0f,0f,1.0f);

	Spine.Skeleton skeleton = yourSkeletonAnimation.skeleton;

	foreach (Spine.Slot slot in skeleton.slots) {
	
		//either tint by slot name

		if(slot.ToString().Contains("hand")){
			slot.R = blackTint.r;
			slot.B = blackTint.b;
			slot.G = blackTint.g;
			slot.A = blackTint.a;
		}


		//or by attachment name


		if(slot.Attachment!=null){
			if(slot.Attachment.Name.Contains("hand")){
				slot.R = blackTint.r;
				slot.B = blackTint.b;
				slot.G = blackTint.g;
				slot.A = blackTint.a;
			}
		}
	}
9 meses depois

Hello,
Sorry to dig this problem, but I don't think this is implemented yet and I tried the code above. It works well in the SpineBoy example but not with an homemade animation, and I really don't understand why. Do you have an idea why or an advice about where I can search ?

Thanks,

It is implemented, should work. What doesn't work?

For an animation, every slot has a new color.
When I played this animation in Spine, the color appears correctly (on the character and in the Draw Order tree).

This color is in the .json file ({"Crete":{"color":[{"time":0,"color":"ffffffff"},{"time":0.0333,"color":"ff8e8aff"},...). But when the animation is played in unity (via skeleton.state.SetAnimation()), the color doesn't appear (with or without the code above).

Thank you for taking the time to help me 🙂

You are using the Skeleton shader?

I really don't know what you are talking about, I am so sorry. I also see now, that the title contains the tk2d package, but I don't use it (juste spine-csharp and spine-unity). Do I have to use it ? (if yes, I have some trouble to made unity works with it because spine-unity contains the same class as it, and juste with spine-tk2d it doesn't compile). Thanks for your time.

It should work in Spine-Unity.

The Shader is something you pick on the Material asset of your character.

If you don't know what Shader and Material are, look them up in the Unity documentation.
It might help clear things up in the future.

But slot coloring relies a few things, including using a compatible shader. Spine comes with Spine/Skeleton shader and if you have that and are using the latest runtime, and didn't do anything weird in the Spine animations, slot colors should work.

I am so ashamed, I was searching in the code, not in Unity.
I changed the shader in the material (from transparent/diffuse to Spine/Skeleton), and it works.
I can't thank you enough !!