Error:Instantiating material due to calling renderer.material during edit mode. This will leak ma...

Error:Instantiating material due to calling renderer.material during edit mode. This will leak materials into the scene. You most likely want to use renderer.sharedMaterial instead.

 var tempMaterial = new Material(renderer.sharedMaterial);
 tempMaterial.color = Color.red;
 renderer.sharedMaterial = tempMaterial;

This gives no errors in edit mode.

你可能感兴趣的:(Error:Instantiating material due to calling renderer.material during edit mode. This will leak ma...)