如何修复Unity中“无法为着色器创建自定义UI”错误?
解决URP项目中Destroyed Building Kit Demo的Shader编辑器错误
问题场景
使用Unity Asset Store的Destroyed Building Kit Demo,项目基于Universal Render Pipeline(URP),多次撤销物体位置移动操作后,点击使用DBK LWRP/Concrete着色器的游戏对象时触发错误:
Could not create a custom UI for the shader 'DBK LWRP/Concrete'. The shader has the following: 'CustomEditor = UnityEditor.ShaderGraph.PBRMasterGUI'. Does the custom editor specified include its namespace? And does the class either derive from ShaderGUI or MaterialEditor? UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
解决方案
- 重新导入异常材质:选中报错物体对应的Material文件,右键选择
Reimport,修复撤销操作可能导致的引用损坏。 - 切换到URP兼容Shader:打开材质面板,将
DBK LWRP/Concrete替换为URP内置的Universal Render Pipeline/Lit;如果资源包提供了URP专用的DBK着色器,优先选择对应版本。 - 修正Shader的编辑器配置:找到
DBK LWRP/Concrete的Shader文件,打开后修改CustomEditor行:// 原配置行 CustomEditor = UnityEditor.ShaderGraph.PBRMasterGUI // 修改为URP对应的命名空间版本 CustomEditor = UnityEditor.Rendering.Universal.ShaderGraph.PBRMasterGUI // 也可直接删除该行,使用默认Shader编辑器 - 清除缓存重启Unity:关闭Unity,删除项目根目录下的
Library文件夹,重新打开项目让Unity重建缓存,解决潜在的缓存异常。 - 重新导入资源包:在Package Manager中找到Destroyed Building Kit Demo,选择
Reimport,恢复可能被损坏的资源文件。
内容的提问来源于stack exchange,提问作者MarkoFire
相关产品推荐
相关产品推荐

