从prefab编辑模式返回场景,场景打不开,有报错

  • Creator 版本:2.4.4

先打开一个出了这个问题场景,再打开随便一个prefab,也不用编辑,直接返回。此时场景打不开,伴随报错。

其它的场景没问题,我就发现这一个场景出问题了。

Failed to restore delete node MainMenuCanvas: TypeError: Cannot read property ‘_onMaterialModified’ of null
at r.undo (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/undo/index.js:1:2578)
at n.undo (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/share/undo.js:1:508)
at d.undo (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor-framework/lib/share/undo.js:1:1201)
at Object.undo (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/undo/index.js:1:7800)
at Object.restore (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/lib/stash-scene.js:1:745)
at d (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/edit-mode/modes/prefab.js:1:361)
at Object.closeWithoutSave (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/edit-mode/modes/prefab.js:1:2533)
at Object.close (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/edit-mode/modes/prefab.js:1:1992)
at Object.run (/Applications/CocosCreator/Creator/2.4.4/CocosCreator.app/Contents/Resources/app.asar/editor/page/scene-utils/edit-mode/index.js:1:889)

然而双击该场景,是可以正常打开的

+1
2.4.2也是经常这么报错。
进入一个prefab,关闭prefab,之前的场景不显示,但不是100%会出现。
这个时候如果预览,游戏跑起来也是异常的,通常我看到报错就直接重启编辑器。

我重启了也不行,不过改成双击场景还是能打开,将就着用

我的已经解决了。里面的一个节点的active设置为false之后出现的。解决方法就是把这个节点的active打开保存一遍,试一下,发现已经不报错并且场景可以正常打开了。然后在按需把这个节点active设置好(保持打开或者关上都行,因为编辑器这时候已经正常了)。
关键问题是得找到"哪个节点让编辑器出出毛病了”,我是复制了一个场景,然后发现复制的这个场景操作后依然会有报错,然后开始删里面的节点,二分法删也行,凭感觉也行,删一半再试。直到发现删掉节点后不报错了,那就是这个节点了。重新弄好之后,版本库里是没有修改的,就是编辑器里面不知道哪里自己错了。