-
Notifications
You must be signed in to change notification settings - Fork 85
Save & Load
daemon3000 edited this page Aug 12, 2014
·
2 revisions
// Saves the configurations in Application.persistentDataPath
InputManager.Save();
// Loads the configurations from Application.pesistentDataPath
InputManager.Load();
// Saves the configurations at a custom path
InputManager.Save("MyGame/Profile/input_config.xml");
// Loads the configurations from a custom path
InputManager.Load("MyGame/Profile/input_config.xml");
private void PlayerPrefsSave()
{
StringBuilder output = new StringBuilder();
InputSaverXML saver = new InputSaverXML(output);
InputManager.Save(saver);
PlayerPerfs.SetString("MyGame.InputConfig", output.ToString());
}
private void PlayerPrefsLoad()
{
if(PlayerPrefs.HasKey("MyGame.InputConfig"))
{
string xml = PlayerPrefs.GetString("MyGame.InputConfig");
using(TextReader reader = new StringReader(xml))
{
InputLoaderXML loader = new InputLoaderXML(reader);
InputManager.Load(loader);
}
}
}
Alternatively you can create a custom input saver and loader by implementing IInputSaver and IInputLoader.