I found that MeshRenderer.material and MeshRenderer.sharedMaterial property could return two different instances if I get sharedmaterial property before get material property。 The code below displays “sharedMaterial:22992”,“material:-849632”
Debug.Log($"sharedMaterial{renderer.sharedMaterial.GetInstanceID()}");
Debug.Log($"material:{renderer.material.GetInstanceID()}");
But if I get material property first I will get exactly same instance。
This is quite wired 'cause that despite two material instances is created, only one material is actually used for rendering, and it seems the material instance returned by material property is actually used, while the instance returned by sharedMaterial is no use but to cause other problems。
Is it designed to work like this?