# LoadStateFromPlayerPrefs(string)

Method in [DialogueRunner](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.unity/yarn.unity.dialoguerunner)

## Summary

Loads all variables from the `UnityEngine.PlayerPrefs` object into the Dialogue Runner's variable storage.

```csharp
public bool LoadStateFromPlayerPrefs(string SaveKey = "YarnBasicSave")
```

## Remarks

This method loads a string containing JSON from the `UnityEngine.PlayerPrefs` object under the key `SaveKey`, deserializes that JSON, and then uses the resulting object to set all variables in [VariableStorage](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.variablestorage).

The loaded information can be stored via the [SaveStateToPlayerPrefs(string)](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.unity/yarn.unity.dialoguerunner/yarn.unity.dialoguerunner.savestatetoplayerprefs) method.

## Parameters

| Name             | Description                                |
| ---------------- | ------------------------------------------ |
| `string` SaveKey | The key to use when storing the variables. |

## Returns

`true` if the variables were successfully loaded from the player preferences; `false` otherwise.

## See Also

* [VariableStorageBehaviour.SetAllVariables(FloatDictionary,StringDictionary,BoolDictionary,bool)](https://docs.yarnspinner.dev/2.3/api/csharp/yarn.unity/yarn.unity.variablestoragebehaviour/yarn.unity.variablestoragebehaviour.setallvariables): Provides a unified interface for loading many variables all at once. Will override anything already in the variable storage.
