Where is ScriptableObject data stored on the asset file?

Very simple question.
I create a Scriptable Object class that stores an array of data:

[CreateAssetMenu(fileName = "ScriptableObjTest")]
public class ScriptableObjTest : ScriptableObject
{
    [HideInInspector]
    public float[] values = new float[0];
...

When I create it, an .asset is created in the project.

When I open the asset it contains:

%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
  m_ObjectHideFlags: 0
  m_CorrespondingSourceObject: {fileID: 0}
  m_PrefabInstance: {fileID: 0}
  m_PrefabAsset: {fileID: 0}
  m_GameObject: {fileID: 0}
  m_Enabled: 1
  m_EditorHideFlags: 0
  m_Script: {fileID: 11500000, guid: 77da5dc8db2a46b4797932fecca75e77, type: 3}
  m_Name: ScriptableObjTest
  m_EditorClassIdentifier:
  values: []

So there’s a guid of an instance in the scene… a file ID that I suppose points to the .asset file…

but where’s the actual data stored?. where are the contents of the array? isn’t the data serialized?

I was doing it wrong. I was creating the data in OnEnable. which stays there but is not saved.
If you create the data on the constructor, it is saved in the file.

2 Likes

Right. :slight_smile: So the values should be in the values array you see at the very bottom. Though in your case it’s empty. The “m_Script” reference is the reference to the MonoScript instance (the script file itself) that describes this scriptable object / MonoBehaviour.

1 Like