Search Issue Tracker

Fixed in 2021.2.X

Votes

0

Found in

2020.3

2021.1

2021.1.21f1

2021.2

Issue ID

1365362

Regression

No

NullReferenceException is thrown when deleting TSS Theme Files

UI Toolkit

-

How to reproduce:
1. Create a new 3D project
2. Create a new TSS Theme File (Assets > Right Click > Create > UI Toolkit > TSS Theme File)
3. Delete the TSS Theme File
4. Open Console and observe NullReferenceException
5. Repeat step 2
6. Open Console and observe a different error

Reproducible with: 2020.3.19f1, 2021.1.21f1, 2021.2.0a2
Not reproducible with: 2021.2.0a3, 2021.2.0b13, 2022.1.0a10
Could not test with: 2019.4.30f1(UI Toolkit unavailable)

Full errors:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.UIElements.StyleSheets.ThemeStyleSheetImporterEditor.LoadThemeAssetDefinitionState (UnityEditor.UIElements.StyleSheets.ThemeAssetDefinitionState extraData, System.String assetPath) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Editor/StyleSheets/ThemeStyleSheetImporterEditor.cs:146)
UnityEditor.UIElements.StyleSheets.ThemeStyleSheetImporterEditor.InitializeExtraDataInstance (UnityEngine.Object extraData, System.Int32 targetIndex) (at /Users/bokken/buildslave/unity/build/External/MirroredPackageSources/com.unity.ui/Editor/StyleSheets/ThemeStyleSheetImporterEditor.cs:137)
UnityEditor.AssetImporters.AssetImporterEditor.ReloadAssetData (System.Int32 index) (at /Users/bokken/buildslave/unity/build/Modules/AssetPipelineEditor/ImportSettings/AssetImporterEditor.cs:730)
UnityEditor.AssetImporters.AssetImporterEditor.CheckForApplyOnClose (System.Boolean isQuitting) (at /Users/bokken/buildslave/unity/build/Modules/AssetPipelineEditor/ImportSettings/AssetImporterEditor.cs:642)
UnityEditor.AssetImporters.AssetImporterEditor.OnDisable () (at /Users/bokken/buildslave/unity/build/Modules/AssetPipelineEditor/ImportSettings/AssetImporterEditor.cs:568)
UnityEditor.ProjectBrowser:DeleteSelectedAssets(Boolean) (at /Users/bokken/buildslave/unity/build/Editor/Mono/ProjectBrowser.cs:2805)

The previous instance of UnityEditor.UIElements.StyleSheets.ThemeStyleSheetImporterEditor has not been disposed correctly. Make sure you are calling base.OnDisable() in your AssetImporterEditor implementation.
UnityEditor.AssetImporters.AssetImporterEditor:InternalSetTargets (UnityEngine.Object[]) (at /Users/bokken/buildslave/unity/build/Modules/AssetPipelineEditor/ImportSettings/AssetImporterEditor.cs:292)

  1. Resolution Note (fix version 2021.2):

    Fixed in: 2021.2.0a3

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.