Search Unity

No mention of EditorUtility.SetDirty() in ScriptableObjects

Discussion in 'Documentation' started by schneckerstein, Dec 23, 2019.

  1. schneckerstein

    schneckerstein

    Joined:
    Dec 6, 2018
    Posts:
    27
    I have a scriptable object where I store genertated data. However, this data was gone after a scene reload, as It was not saved to the actual asset. It took me hours to figure out that I had to call EditorUtility.SetDirty() on the Scriptable Object.

    As I think this is not a bug, a mention of this function in the docs for ScriptableObjects would be great. :)
     
  2. CharlesWard

    CharlesWard

    Unity Technologies

    Joined:
    Apr 19, 2017
    Posts:
    12
    Thanks for the feedback, @schneckerstein. Can you elaborate on how and when you are setting the values of your scriptable object? In my test, I tried setting the value of a scriptable object from a MonoBehaviour component and did not find that calling SetDirty() was necessary. But perhaps you are doing it in a different way...
     
  3. schneckerstein

    schneckerstein

    Joined:
    Dec 6, 2018
    Posts:
    27
    I narrowd down the issue, and I guess its a bug:
    If you write to a array that has been previously null, the changes will not apply unless you call SetDirty(). If the array wasn't null before, everything works fine.

    Case 1209196
     
unityunity