Harald
Hello Harald, thanks for you help!
When I use sharedMaterial can run perfect, sharedMaterial will change unity local material file, we use SVN to manage project, it's a trouble for us. So i want to create a runtime material instance and change it's stencil value.But by this way, the spine character start blink.That's the main problem.
I have try CustomMaterialOverride. But it's seems no effect.
Here is the code
public static void ChangeCustomMaterialOverride(GameObject gameObject)
{
SkeletonAnimation skeletonAnimation = gameObject.GetComponent<SkeletonAnimation>();
if (skeletonAnimation != null)
{
foreach(AtlasAssetBase Base in skeletonAnimation.SkeletonDataAsset.atlasAssets)
{
Material orgMat = Base.PrimaryMaterial;
Debug.LogWarning(orgMat.GetInstanceID());
Material newMat = Material.Instantiate(orgMat);
Debug.LogWarning(newMat.GetInstanceID());
skeletonAnimation.CustomMaterialOverride[orgMat] = Material.Instantiate(newMat);
}
}
}
Now I still use sharedMaterial, the ID value between orgMat and newMat are different, but it's still change unity local material file
; ;