unity撤销上一步_Unity5.0_Undo 撤销_软件教程_资源库

Unity的撤销系统通过在更改对象前保存其状态来工作,类似于创建备份。使用RegisterUndo或RegisterSceneUndo函数可在执行可撤销更改前注册操作。在完成注册后,Unity将自动处理撤销和重做。RegisterUndo适用于单个或多个对象的即时更改,而RegisterSceneUndo虽然较慢且内存需求高,但能处理对象创建和销毁等操作。
摘要由CSDN通过智能技术生成

摘要:Unity5.0_Undo 撤销_软件教程_资源库

Undo  撤销

Lets you register undo operations on specific objects you are about to perform changes on.

让你在特定物体上注册撤销操作,以便你以后执行这个操作。

Note: This is an editor class. To use it you have to place your script in Assets/Editor inside your project folder. Editor classes are in the UnityEditor namespace so for C# scripts you need to add "using UnityEditor;" at the beginning of the script.

注意:这是一个编辑器类,如果想使用它你需要把它放到工程目录下的Assets/Editor文件夹下。编辑器类在UnityEditor命名空间下。所以当使用C#脚本时,你需要在脚本前面加上 "using UnityEditor"引用。

The undo system in Unity works by saving the state of one or more objects before performing a change on those objects.  It is similar to taking a backup. To undo the change later, the saved state is restored.  Since this reverts the objects to the state they had before performing the change, it will be as if the change never happened.

撤销功能,是通过事先对一个或者多个对象状态的保存来实现的,这更像是一个备份。在稍后执行撤销时,备份被恢复,好像从未发生过任何事情。

For instant changes to one or more objects, simply call functions RegisterUndo or RegisterSceneUndo before performing the change that it should be possible to undo.

瞬间撤销一个或多个物体,只需调用函数RegisterUndo 或者 RegisterSceneUndo.

This is all that needs to be done. Unity will automatically handle Undo and Redo for you after that. PerformUndo and PerformRedo should normally not be used unless you want to create your own  user interface to the undo system in addition to the user interface Unity already provides.

这就是需要做的全部。Unity会自动处理撤销和重做。PerformUndo和PerformRedo通常不使用,除非你想建立自己的用户界面实现撤销系统。

Using RegisterUndo is most efficient for actions that change one or more objects. RegisterSceneUndo is slower and requires more memory, but it can be used in all cases,  and is required for actions that create or destroy objects.

改变一个或多个对象,使用RegisterUndo最有效。RegisterSceneUndo比较缓慢,需要占用更多的内存,但它可以用在所有的情况下。

Certain operations, such as dragging, consist of many small incremental changes.  Typically it is not desired to create an undo step for each of these small changes.  For example, if the user performs an undo after a dragging operation,  it is expected that the object is reverted back to the state it had before the dragging started.  The functions SetSnapshotTarget, CreateSnapshot, and RegisterSnapshot are available to handle cases like this.

某些特定的操作,例如拖动,由许多连续变化组成。典型的做法不是想要恢复每一个小的变动。例如,如果用户执行撤销操作,目的是回到拖放开始。SetSnapshotTarget,CreateSnapshot和RegisterSnapshot能够处理这样的情况。

Class Functions类函数RegisterUndo

Register the state of one or more objects so the user can later undo back to that state.

记录一个或者多个对象的状态,为了以后执行撤消时恢复状态。

RegisterSceneUndo

Register the state of the entire scene so the user can later undo back to that state.

记录整个场景以便用户以后恢复。

RegisterCreatedObjectUndo

Register the state of a Unity Object so the user can later undo back to that state.

记录Unity物体的状态,为了以后执行撤消时恢复。

SetSnapshotTarget

Set the objects modified by the GUI or Handles so they can undo properly.

通过GUI或Handles所做的修改设置,这样就可以妥善的恢复。

ClearSnapshotTarget

Clear the snapshot target set with SetSnapshotTarget.

清除SetSnapshotTarget设置。

CreateSnapshot

Save the current state of all objects set with SetSnapshotTarget to internal snapshot.

保存对象当前的状态快照,这些对象是通过SetSnapshotTarget设置的。

RestoreSnapshot

Restore the snapshot state made with CreateSnapshot.

恢复通过CreateSnapshot制作的快照状态。

RegisterSnapshot

Register the snapshot state made with CreateSnapshot so the user can later undo back to that state.

记录通过CreateSnapshot制作的状态快照,用户可以稍后恢复到那个状态。

PerformUndo

Perform an Undo operation.

执行一个撤销操作。

PerformRedo

Perform an Redo operation.

执行一个重做操作。

ddf946631bdb98394aa2ce80cf334144.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值