if (skinnedMeshRenderer != null){
skinnedMeshRenderer.GetPropertyBlock(color);
Color newCol = color.GetColor("_Color");
newCol.a = alpha;
color.SetColor("_Color", newCol);
skinnedMeshRenderer.SetPropertyBlock(color);
}
The same code works for a regular Mesh Renderer, but not the skinned mesh renderer. I even used material.HasProperty and that returns true. GetColor can’t find “_Color” on skinned mesh renderers… or any color for that matter as I tried them all…
Since a PropertyBlock represents per-instance overrides, if there are no overrides, it does not contain any values at all. So if you currently have no per-instance overrides, your “workaround” seems to be the correct way of getting the color.
Note that a PropertyBlock is just a data collection, essentially some sort of dictionary that can hold any property overrides you want to use / apply for an instance. Getting the PropertyBlock only gives you the overrides, not every value in th shared material that the renderer uses. At least that’s what I get from the documentation.
Also note that calling .material will create a copy (new instance) of the material.
If you’re looking for a ‘default value’, you should be grabbing it from .sharedMaterial instead.