Referencing Scriptable Objects

I have a public variable in a script attached to my player that allows for a specific scriptable object type to be referenced. Obviously, I could easily drag a scriptable object asset into this field, but that doesnt solve my problem. I need to be able to change the scriptable object asset programmatically with a function called by an onclick event.

I think something like this would work for my intended purpose:

public Ghost selectedGhost;
void ChangeSelectedGhost(){
	selectedGhost = ***Reference to scriptable object asset***;

Does anyone know if this is possible? Thanks for any help ahead of time.

public List<Ghost> allGhosts;

Assign all the ScriptableObjects in editor, take the reference from there, based on what you need it should be the easiest way to resolve the problem.

note that this is more efficient than finding it from resources folder at runtime

public Ghost ghosts;

void SomeFunction(){
       ghosts = Resources.FindObjectsOfTypeAll<Ghost>();

This will find all assets of type Ghost, after that you can set your selectedGhost var to reference any of the given objects, but that depends on what you are trying to achieve. Cheers.