Search Issue Tracker

Active

Under Consideration for 2022.3.X

Votes

6

Found in

2022.3.19f1

2023.2.8f1

2023.3.0b5

6000.0.0b11

Issue ID

UUM-63982

Regression

Yes

"InvalidCastException: Specified cast is not valid." error is thrown when scripts are compiled with PlayerBuildInterface.CompilePlayerScripts in Play Mode

--

-

Reproduction steps:
1. Open the “ReproProject“ project
2. Open the Preferences window (Edit > Preferences)
3. Set “Script Changes While Playing“ to “Recompile After Finished Playing“ in the General tab
4. Set “Auto Refresh” to “Enabled“ in the Asset Pipeline tab
5. Compile the scripts (ET > Compile)
6. Enter Play Mode
7. Open the “Assets/Scripts/HotfixView/Client/Demo/Opera/OperaComponentSystem“ script
8. Insert “Debug.Log(“123“);“ after line 19
9. Save the script
10. Repeat step 5
11. Exit Play Mode
12. Repeat step 7
13. Delete the “Debug.Log(“123“);“ line
14. Repeat step 9
15. Observe the Console window

Expected result: The scripts are recompiled and no errors are thrown in the Console window
Actual result: “InvalidCastException: Specified cast is not valid.“ error is thrown in the Console window

Reproducible with: 2022.2.0b16, 2022.3.19f1, 2023.2.8f1, 2023.3.0b5
Not reproducible with: 2021.3.34f1
Couldn’t test with: 2022.1.0a1, 2022.1.24f1, 2022.2.0a1, 2022.2.0b15 (due to RecompileAfterFinishedPlaying feature missing, compilation errors and UUM-14004)

Reproducible on: Windows 11 Pro (22H2)
Not reproducible on: No other environment tested

Comments (4)

  1. xiaodu452981287

    Mar 08, 2024 03:31

    The complete error log is as follows:

    InvalidCastException: Specified cast is not valid.
    UnityEditor.Scripting.ScriptCompilation.EditorCompilation.CompleteActiveBuildWhilePumping ()

  2. xiaodu452981287

    Mar 08, 2024 02:22

    2022.3.20f1,Packaging bundle occasionally failed, this error occurred

  3. longsl

    Mar 01, 2024 07:19

    correct my comment information:> Reproduction in 2022.3.0f1

  4. longsl

    Mar 01, 2024 07:18

    Reproduction in 2023.3.0f1

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.