资源大湿 发表于 2020-4-9 13:41

Material Leak in Editor

当我试图改变材质时,报错:
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.提示有泄漏

资源大湿 发表于 2020-4-9 13:41

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

如提示修改为sharedMaterial可在editor模式下避免报错
页: [1]
查看完整版本: Material Leak in Editor