Yarnspinner SetValue() method

I’ve recently started playing around with Yarnspinner, but I need to be able to set variables from a C# script. My current attempt using the following code:

public class YarnVariableHolder : MonoBehaviour
{

    public string PCName = "Alex";

    public void Awake()
    {
        InMemoryVariableStorage.SetValue("PCName", PCName);
    }
}

returns a “an object reference is required for the non-static field” error, and I am not sure how to fix it.

any help is greatly appreciated :slight_smile:

That means that InMemoryVariableStorage is not a static class and can thus not be used without an instance of it.

Thanks, but how do?

Depends entirely on the implementation of your InMemoryVariableStorage.