Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class ScriptableObjectLoader : EditorWindow
private static readonly int TYPE = 0;
private static readonly int NAME = 1;
private static readonly int IMAGE_PATH = 2;
[MenuItem("Tools/Load Scriptable Object Data")]
public static LoadScriptableObjectsFromFile()
string path = "Assets/Cores/SomeCoolValuesForOurSO.csv";
using (var reader = new StreamReader(path))
// first line is the table header, we can skip or do something with it
while (!reader.EndOfStream)
var line = reader.ReadLine();
var values = line.Split(',');
//Create new instance of the specific type read from file
// Note: you can also use the type system CreateInstance<MySOType>()
var newScriptableObject = (MySOType)ScriptableObject.CreateInstance(values[TYPE]); = values[NAME];
// Create the asset on the file system
AssetDatabase.CreateAsset(newScriptableObject, "Assets/MyDynamicallyCreatedSOFolder/" + values[NAME] + ".asset");
newScriptableObject.sprite = AssetDatabase.LoadAssetAtPath<Sprite>(values[IMAGE_PATH]);
// optional
// AssetDatabase.SaveAssets();
// AssetDatabase.Refresh();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment