Search Issue Tracker


Fixed in 2022.3.11f1, 2023.1.13f1, 2023.2.0b7, 2023.3.0a1



Found in





Issue ID




[Undo] “Transform is used before Awake” error appears when accessing GameObject transform from “OnDestroy” if the GameObject is deleted by an Undo operation



How to reproduce:
1. Open the user’s attached “” project
2. In the Hierarchy window select “Cube” GameObject
3. Duplicate “Cube” GameObject and press undo
4. Observe the Console window

Expected result: No error
Actual result: “Transform is used before Awake. Are you trying to access scene objects from assets (ScriptableObject.OnValidate)?” or “Illegal transform access. Are you accessing a transform position from OnValidate?” error appears

Reproducible with: 2022.1.0a12, 2022.1.24f1, 2022.2.12f1, 2023.1.0b9, 2023.2.0a8
Not reproducible with: 2020.3.46f1, 2021.3.21f1, 2022.1.0a11

Reproduced on: macOS 13.2.1 (Intel)

  1. Resolution Note (fix version 2023.3.0a1):

    Accessing Transform data from “OnDestroy” during an Undo operation is no longer allowed. Transforms are detached from each other and reassembled during Undo operations so we can therefore no longer return any transform data like position and rotation during Undo operations. Instead a better error messsage is now logged so it can be fixed on from the client side: "Transform cannot be used during an Undo operation. Use 'Undo.isProcessing' to check before accessing."

    Example code for a Monobehaviour that is fixed up and handles the Undo case:

    public class test : MonoBehaviour
    void OnDestroy()
    if (!Undo.isProcessing)
    Debug.Log("Editor: " + transform.position);
    Debug.Log("Player: " + transform.position);

  2. Resolution Note (fix version 2023.1.13f1):

    Fixed in: 2023.1.13f1

  3. Resolution Note (fix version 2022.3.11f1):

    Fixed in: 2022.3.11f1

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.