I’m trying to find a way to assign public variables in the inspector through an editor script (in Edit mode).
So, basically I have this wizard that dynamically writes a script based on what assets are available. It creates a code for a few lists named by the particular features of the assets in my project. So for example, say I have assets with the label “shoot sounds”, a list is created with the name “shoot sounds” in my code.
Now, I’ve already have the wizard that writes the code and it works fine, what I now want, is to store each element in the corresponding list by pressing a button.
…But how to assign the value in the inspector thorugh code? Set it dirty, maybe?
Well, sorry for the bother, I just couldn’t remember how to do it.
Turns out that setting the script dirty did the trick. So, after assigning the value, you just write: UnityEditor.EditorUtility.SetDirty(yourScript); and it gets assign in the inspector.