private static void LoadAndMerge() { // Load default keys from resources... var defaultKeys = GameIO.ResourceToObject <Dictionary <string, KeyCode[]> >(GameIO.DefaultInputPath); int defNum = defaultKeys.Count; // Load current keys from file... var currentKeys = GameIO.FileToObject <Dictionary <string, KeyCode[]> >(GameIO.CurrentInputPath); if (currentKeys == null) { currentKeys = new Dictionary <string, KeyCode[]>(); } // Merge current keys into default keys, but current keys have priority. foreach (var pair in currentKeys) { if (defaultKeys.ContainsKey(pair.Key)) { defaultKeys[pair.Key] = pair.Value; } else { defaultKeys.Add(pair.Key, pair.Value); } } bindings = defaultKeys; Debug.Log(string.Format("Loaded {0} default key bindings, {1} current key bindings, and merged to create {2} bindings.", defNum, currentKeys.Count, defaultKeys.Count)); }