Unity编辑器 - Undo的坑
编辑器通过脚本中改变值,Undo.RecordObject可能会无效,应该使用:
Undo.RegisterCompleteObjectUndo(Object objectToUndo, string name)
该方法会记录对象的完整状态的拷贝。
The Unity documentation has been updated since:
https://docs.unity3d.com/ScriptReference/Undo.RegisterCompleteObjectUndo.html
https://docs.unity3d.com/ScriptReference/Undo.RegisterFullObjectHierarchyUndo.htmlUndo.RegisterCompleteObjectUndo(Object objectToUndo, string name) will
record a copy of the full state of the object that it will keep,
unlike Undo.RecordObject(Object objectToUndo, string name) that will
only keep a copy of the state until the end of the frame to compute a
diff.By the way, I ju

Unity编辑器在脚本中更改值时,使用Undo.RecordObject可能无法正确撤销操作。应改用Undo.RegisterCompleteObjectUndo或Undo.RegisterFullObjectHierarchyUndo。这两个方法分别记录对象的完整状态和对象及其所有子对象和组件的状态,确保在复杂情况下能正确计算差异。错误消息'Generating diff of this object for undo...'提示应使用Undo.RegisterCompleteObjectUndo来处理脚本属性变更。
最低0.47元/天 解锁文章
7万+

被折叠的 条评论
为什么被折叠?



