How to reproduce:
- Open the attached “IN-154909” project
- Open the “Sample Scene” scene
- In the Hierarchy tab, expand “PlayerHUD” > “#Header” > “#HeaderLeft” and select the “#SpinCoinIcon” VisualElement
- Open the “Animation” window (Ctrl + 6)
- In the top bar of the “Animation” window near the record button, enable “Preview” mode
- In the left part of the “Animation” window, expand “Background Image”
- Change “Background Image.gradient.angle” value to 3 and save the changes (Ctrl + S)
- In the Hierarchy tab, unselect and select “#SpinCoinIcon” VisualElement
- In the “Animation” window, repeat steps 6 and 7, change “Background Image.gradient.angle” value to 4 and save the changes (Ctrl + S)
- Observe the result in the Console
Actual result: The “NullReferenceException: Object reference not set to an instance of an object” error is thrown
Expected result: The animation is saved without errors
Reproducible with: 6000.6.0a6, 6000.6.4f1, 6000.7.0b3, 7000.0.0a1
Could not test with: 6000.0.1f1, 6000.0.85f1, 6000.3.25f1, 6000.6.0a5 (Animating UI Toolkit elements in the Animation window is not available)
Reproducible on: Windows 11 Enterprise (25H2)
Not reproducible on: No other environments tested
Notes:
- Any property in the “Animation” window could be changed to any value to reproduce the bug
- The “Animation” window could also be opened without a hotkey (“Window” > “Animation” > “Animation”)
- In the 6000.6.0a6 and 6000.6.4f1, step 7 could be skipped (in 6.6 “Background Image” is absent)
- In 6000.6, “Enable UI Toolkit Animation” and “Enable in-scene UI Authoring” (Project Settings > UI Toolkit) must be enabled, and the clip must be assigned with -unity-animation-clip instead of animation-name