From 689daa147ae0da9d3d38e87735875d1d236ad36d Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 21 Feb 2022 18:26:30 +0100 Subject: [PATCH] [unity] Minor: example script documentation improved (CustomMaterialOverride). --- .../Spine Examples/Scripts/MaterialReplacementExample.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/spine-unity/Assets/Spine Examples/Scripts/MaterialReplacementExample.cs b/spine-unity/Assets/Spine Examples/Scripts/MaterialReplacementExample.cs index df409c61b..16b854d6b 100644 --- a/spine-unity/Assets/Spine Examples/Scripts/MaterialReplacementExample.cs +++ b/spine-unity/Assets/Spine Examples/Scripts/MaterialReplacementExample.cs @@ -47,6 +47,13 @@ namespace Spine.Unity.Examples { MaterialPropertyBlock mpb; void Start () { + // Use the code below to programmatically query the original material. + // Note: using MeshRenderer.material will fail since it creates an instance copy of the Material, + // MeshRenderer.sharedMaterial might also fail when called too early or when no Attachments + // are visible in the initial first frame. + if (originalMaterial == null) + originalMaterial = skeletonAnimation.SkeletonDataAsset.atlasAssets[0].PrimaryMaterial; + previousEnabled = replacementEnabled; SetReplacementEnabled(replacementEnabled); mpb = new MaterialPropertyBlock();