• Editor
  • unity spine material Individual allocation

Let me explain in detail what I want.

As you can see, there are two characters with the same materials.

In this situation, if I change the value of "1_Doi_Material(URP)" of the custom slot material, both characters will be affected by the material, and the bodies of both characters will change.

What I want is for both characters to have their own ""1_Doi_Material(URP)"".

So, if I change the value of one character's material, the shader of one character's body will change.

I'm not sure which method is the most correct and the solution.

Related Discussions
...

To achieve individual material allocation for each character in Unity using Spine, you need to create unique instances of the material for each character. This way, changes to one character's material won't affect the other. Here are the steps to do this:

  1. Create Material Instances: Instead of using the shared material, create a new instance of the material for each character. This can be done programmatically.

  2. Assign the Material Instances: Assign these unique material instances to the respective characters.

Here is a code example to illustrate this:

using UnityEngine;
using Spine.Unity;

public class UniqueMaterialAssignment : MonoBehaviour
{
    public SkeletonRenderer skeletonRenderer;
    public Material originalMaterial;

    void Start()
    {
        // Create a new instance of the material
        Material newMaterial = new Material(originalMaterial);

        // Assign the new material to the skeleton renderer
        skeletonRenderer.CustomMaterialOverride.Add(originalMaterial, newMaterial);
    }
}

In this example:

  • skeletonRenderer is the component attached to your character.
  • originalMaterial is the shared material you want to duplicate.

You can attach this script to each character and assign the SkeletonRenderer and originalMaterial in the Unity Inspector.

Additional Resources

For more detailed information, you can refer to the following sections in the spine-unity documentation:

These sections provide more insights and examples on how to handle materials in Spine-Unity.

    Spinebot

    I got what I wanted.

    Thank you so much for your reply.