Search Issue Tracker

Duplicate

Votes

14

Found in

2019.4

2020.3

2021.3

2021.3.2f1

2022.1

2022.2

Issue ID

1426900

Regression

No

Error "Destroy may not be called from edit mode! Use DestroyImmediate instead." is shown when exiting Play Mode

UI Toolkit

-

How to reproduce:
1. Open the attached project "UIToolTip"
2. Click Play
3. Click Play again to exit Play Mode
4. Observe the Console

Expected result: Console shows no errors
Actual result: Console shows "Destroy may not be called from edit mode! Use DestroyImmediate instead." error

Reproduced in: 2019.4.38f1, 2020.3.33f1, 2021.3.1f1, 2022.1.0b16, 2022.2.0a15

Reproduced on: Windows 11 Pro

Comments (6)

  1. sugiharam2

    Mar 10, 2024 03:47

    When I tried downgrading the InputSystem version, the error disappeared.

    Unity 2023.2.13f1

    Input System 1.7.0 > error
    Input System 1.6.3 > error
    Input System 1.5.0 > no error
    Don't use Input System > no error

  2. berber_hunter

    Dec 29, 2023 17:24

    This is not resolved!!!!

  3. Pchan_Cegepdefi

    Dec 11, 2022 07:31

    [Solution] I had the same problem. I double clicked on the error message and the script "EventSystem.cs" opened at line #413. The error said "Use DestroyImmediate instead". So I replace the line "panel.destroyed += () => Destroy(go);" TO "panel.destroyed += () => DestroyImmediate(go);"

  4. bilalakil

    Oct 03, 2022 00:00

    Also looking for the duplicate ticket so I can vote on it. Note that this bug prevents some build attempts from succeeding.

  5. generatedgoblin

    Aug 12, 2022 13:10

    Can't find the duplicate, can this be re-opened?

  6. severeZzz

    Jun 14, 2022 17:35

    Could you please add a link to the original ticket? "Duplicate" is not informative.

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.