docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Class UndoBlock

    Represents a series of object actions as a single undo-operation.

    Inheritance
    object
    UndoBlock
    Implements
    IDisposable
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Unity.XR.CoreUtils
    Assembly: solution.dll
    Syntax
    public class UndoBlock : IDisposable
    Remarks

    UndoBlock methods work in both Edit mode and Play mode. In Play mode undo-operations are disabled. This class mirrors the normal functions you find in the Undo class and collapses them into one operation when the block is complete.

    Examples

    Proper usage of this class is:

    using (var undoBlock = new UndoBlock("Desired Undo Message"))
    {
        undoBlock.yourCodeToUndo()
    }

    Constructors

    Name Description
    UndoBlock(string, bool)

    Initialize a new UndoBlock.

    Methods

    Name Description
    AddComponent<T>(GameObject)

    Adds a component to the game object and registers an undo operation for this action.

    Dispose()

    This code added to correctly implement the disposable pattern.

    Dispose(bool)

    Dispose of this object.

    RecordObject(Object)

    Records any changes done on the object after the RecordObject function.

    RegisterCreatedObject(Object)

    Register undo operations for a newly created object.

    SetTransformParent(Transform, Transform)

    Sets the parent transform of an object and records an undo operation.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)