Search Issue Tracker

By Design

Votes

10

Found in

2020.2.0a16

2020.2.0a17

Issue ID

1262293

Regression

No

Editor throws warning when adding a Scriptable Object as a sub asset using AssetDatabase.AddObjectToAsset

Asset - Database

-

How to reproduce:
1. Open attached project "case1262293.zip"
2. Select "MainAsset" in the Project window
3. Click the "Add" button in the Inspector window
4. Observe the warning in the Console window

Expected: No warnings in the Console window
Actual: Warning "Importer(NativeFormatImporter) generated inconsistent result" is thrown in the Console window

Reproducible with: 2020.2.0a16, 2020.2.0a18
Not reproducible with: 2018.4.25f1, 2019.4.4f1, 2020.1.0b16, 2020.2.0a15

  1. Resolution Note:

    Although the warning is new, it is correctly flagging an issue.

    When using AssetDatabase.AddObjectToAsset(), the changes in memory must be saved to disk using AssetDatabase.SaveAssets() . Failure to do this causes the inconsistent result warning, because the in-memory changes are not synchronised with the asset on disk.

    The documentation is being updated to explicitly call this out.

Comments (2)

  1. NikoBay

    Nov 18, 2021 08:25

    Using AssetDatabase.AddObjectToAsset() does not solve the problem and even creates more error:
    "The asset at Assets/***.asset has been scheduled for reimport during the Refresh loop and Loading of it has been attempted.
    Doing this can lead to the AssetDatabase returning two versions of the same asset...."
    How can we open this issue again?

  2. onembitshorde

    Nov 13, 2020 23:57

    This is actually happening to me in 2020.2.0b11. Mostly with Scriptable Objects and by reference.

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.