Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

No mention of EditorUtility.SetDirty() in ScriptableObjects

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

  1. schneckerstein

    schneckerstein

    Joined:
    Dec 6, 2018
    Posts:
    29
    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:
    15
    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:
    29
    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