找回密码
 立即注册
查看: 619|回复: 1

[随便问问] Material Leak in Editor

[复制链接]
发表于 2020-4-9 13:41 | 显示全部楼层 |阅读模式
当我试图改变材质时,报错:
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模式下避免报错
懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Unity开发者联盟 ( 粤ICP备20003399号 )

GMT+8, 2024-11-14 03:50 , Processed in 0.092674 second(s), 25 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表