Skip to content

Instantly share code, notes, and snippets.

@SiarheiPilat
Created November 21, 2020 23:44
Show Gist options
  • Save SiarheiPilat/c2937a03fa4201c2913cc0e66628de2b to your computer and use it in GitHub Desktop.
Save SiarheiPilat/c2937a03fa4201c2913cc0e66628de2b to your computer and use it in GitHub Desktop.
How to set ScriptableObject values in project files.
class SciptableObjectValueSetter {
// 'Mechanic' is a ScriptableObject
var so = (Mechanic)AssetDatabase.LoadAssetAtPath("Assets/SOs/Abilities.asset", typeof(Mechanic));
so.SomeValue = "boop";
// And this ensures that the value is saved not only in the inspector and also survives all kinds of reloads!
EditorUtility.SetDirty(so);
AssetDatabase.SaveAssets();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment