//fill in keycode map and config tables void Awake() { //print( " : " + DefaultKeys.Length ); //destroys the manager if one already exists if(_selfReference != null){ Destroy(this); return; } //Prepare self reference _selfReference = this; //add the keycodes and joystickcodes to a map for easy lookup _keycodemap = new Hashtable(); foreach (KeyCode kc in KeyCode.GetValues(typeof(KeyCode))){ //skip any built in joystick buttons if(kc >= KeyCode.JoystickButton0 && kc <= (KeyCode.JoystickButton0 + 20*5)-1) { continue; } if(!_keycodemap.Contains(kc.ToString().ToLower())) { _keycodemap.Add( kc.ToString().ToLower(), (int)kc); } } foreach (JoyCode jc in JoyCode.GetValues(typeof(JoyCode))){ if(!_keycodemap.Contains(joyMapAdd+jc.ToString().ToLower())) { _keycodemap.Add( joyMapAdd+jc.ToString().ToLower(), (int)jc); } } //set the used configs to the default buttons ResetToDefault(out _configs); //load the configs from preferences //LoadConfig(ref _configs, SAVE_PREF_NAME); //get the total amount of players needed foreach(KeyConfig kc in defaultKeys){ if(kc.PlayerNum > _totalPlayers) _totalPlayers = kc.PlayerNum; } }
//TODO: Make into "self" variable //returns a reference to this manager - and creates it if it was never created public static NewCustomInputManager GetReference() { if(_selfReference == null){ _selfReference = new GameObject("InputManager").AddComponent<NewCustomInputManager>(); } return _selfReference; }