Scriptable Object - cloning with dynamic data

Say I have a Scriptable Object with these data fields:

  • Name (name of file)
  • FileType (txt, pdf, xls, etc…)
  • DataPath (where the file is located)

I also have a folder with say 10 documents in it.

What I want to do, at run time:
Clone the scriptable object, and then populate those fields, for each document I have.
I’ve already got my code to find the folder, and make a list with the names, file types, and datapaths, I just need to pass that those values to the scriptable objects.

Is this possible? Or do they not work that way?
Otherwise, I’d have to create 10 scriptable objects, and fill the fields in manually. This is not an option, as the number of documents in the folder may change from day to day, so this needs to be dynamic.

So something like

void OnEnable()
    foreach (File foo in FileList)
        scriptableobject.Name =;
        scriptableobject.FileTye = foo.filetype;
        scriptableobject.Datapath = foo.path;

To take the template scriptable object, make 10 of them, each one with its data corresponding to a different document in my folder.

Create a FileItem class which will hold the data of a single file.

public class FileItem
    public string name;
    public FileType fileType;
    public string dataPath;

And create a Scriptable Object that will hold the array of these file items.

public class Files : ScriptableObject
    public FileItem[] fileItems;

Now you can add your scanned files data to this array.

void OnEnable()
    // Set the length of fileItems array.
    scriptableobject.fileItems = new FileItem[FileList.length];

    // Now populate the array.
     for (int i = 0; i < FileList.length; i++)
     { = FileList*.name;*_

scriptableobject.fileItems_.fileTye = FileList*.filetype;
scriptableobject.fileItems.datapath = FileList.path;

Note that you can only modify and save the Scriptable Object in Editor only. Also you can use SerializedObject to update the data as it is preferred way._