WindArt

I need get originalMaterial for change material.
I want to do this through code, not through an inspector. Can anyone help with this?

I am using this code to change material. Get originalMaterial = skeletonAnimation.GetComponent<MeshRenderer>().material not working.
skeletonAnimation.CustomMaterialOverride.Add(originalMaterial, newMaterial);
WindArt
  • Postovi: 5

Harald

If originalMaterial = skeletonAnimation.GetComponent<MeshRenderer>().material returns null, you most likely called it too early, before it has been assigned for the first time.

You could also access the first atlas page material in this way:
Material material = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial; // or via .Materials
Avatar
Harald

Harri
  • Postovi: 3992


Natrag na Unity