Search Issue Tracker

Fixed in 2021.1.X

Fixed in 2020.1.X, 2020.2.X

Votes

1

Found in

2020.1

2020.1.2f1

2020.2.0a16

Issue ID

1271740

Regression

Yes

Error is thrown upon entering Play Mode when Tile Palette window is present and a GameObject with a Grid Component is selected

2D

-

How to reproduce:
1. Open the attached "1271740 repro" project
2. Open the "SampleScene" Scene from the Assets folder
3. Select the "Grid" GameObject from the Hierarchy window
4. Switch the Inspector window to Debug mode
5. Enter and exit Play Mode
6. Repeat step 5 until a NullReferenceException error is thrown in the Console window

Expected results: no errors are thrown in the Console after entering Play Mode
Actual results: NullReferenceException error is thrown upon entering Play Mode

Reproducible with: 2020.1.3f1, 2020.2.0a16, 2020.2.0a21
Not reproducible with: 2018.4.26f1, 2019.4.9f1, 2020.2.0a15

Notes:
-Sometimes the issue reproduces on the first attempt but usually requires up to 7 attempts
-Tile Palette window must be open or docked somewhere with a Palette selected (an empty Palette in the selection is enough to reproduce the issue)
-A GameObject with a Grid Component must be selected in order to reproduce the bug
-The issue only reproduces when the Inspector window is in Debug mode.
-The Inspector and Tile Palette windows don't have to be visible, having them docked somewhere in the Editor is enough
-The full error message is:
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.GameObjectInspector.ClearPreviewCache () (at <1ad84465318248ca98d7f06a0a057e63>:0)
UnityEditor.GameObjectInspector.ReloadPreviewInstances () (at <1ad84465318248ca98d7f06a0a057e63>:0)
UnityEditor.GameObjectInspector.OnForceReloadInspector () (at <1ad84465318248ca98d7f06a0a057e63>:0)
UnityEditor.Tilemaps.GridPaintPaletteWindow:OnDisable() (at E:/UnityVersions/2020.2/2020.2.0a21_3e0d5f775006/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.2d.tilemap/Editor/GridPaintPaletteWindow.cs:842)

  1. Resolution Note (fix version 2021.1):

    Fixed in 2021.1.0a1

  2. Resolution Note (fix version 2020.2):

    A fix for this issue is available on Unity 2020.2.0b8 and above

  3. Resolution Note (fix version 2020.1):

    A fix for this issue is available on Unity 2020.1.10f1 and above

Comments (2)

  1. JDSherbert

    Aug 02, 2021 23:52

    Unity 2020.1.3f1
    I managed to fix the issue by replacing the line of code at line cs817 to this:

    if(clipboardView) DestroyImmediate(clipboardView);

    Hope this helps.

  2. pitchblende

    Jun 12, 2021 04:34

    This still occurs occasionally for me with Unity 2020.3.3f1 - I think it might be a race condition because it seems intermittent. In my case I see it appear, sometimes, when the Tile Palette is open and I have an object in my scene with a TileMap component. I'm not sure but it seems to be related to which object is selected when I start the Player.

    Closing and reopening the Tile Palette made the issue go away, for a while.

    Looks like this is a related issue: https://issuetracker.unity3d.com/issues/error-is-thrown-when-entering-the-play-mode-while-inspector-and-tile-palette-are-opened-and-gameobject-with-grid-is-selected

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.