Created
November 21, 2020 23:44
-
-
Save SiarheiPilat/c2937a03fa4201c2913cc0e66628de2b to your computer and use it in GitHub Desktop.
How to set ScriptableObject values in project files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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