Skip to content

Save & Load

daemon3000 edited this page Aug 12, 2014 · 2 revisions

Default save and load

//	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");        

Saving and loading using PlayerPrefs

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.

Clone this wiki locally