void Awake() { instance = this; // Here, the key bindings are set to what is stored in the save file. If it is unable to find the stored (KeyCode), then the named input is set to a defined default KeyCode. fullPath = Application.dataPath + "/SaveData/Data/" + fileName + ".xml"; if (File.Exists(fullPath)) { // Load it Load(); forwardText.text = keys["Forward"].ToString(); backwardText.text = keys["Backward"].ToString(); jumpText.text = keys["Jump"].ToString(); leftText.text = keys["Left"].ToString(); rightText.text = keys["Right"].ToString(); } else { // Add defaults // set out keys to the preset keys we may have saved, else set the keys to default keys.Add("Forward", (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Forward", "W"))); keys.Add("Backward", (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Backward", "S"))); keys.Add("Jump", (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Jump", "Space"))); keys.Add("Left", (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Left", "A"))); keys.Add("Right", (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("Right", "D"))); } }
void Awake() { forward = Camera.main.transform.forward; forward.y = 0; forward.Normalize(); right = Quaternion.Euler(new Vector3(0, 90, 0)) * forward; playerInput = GetComponent <MenuInputHandler>(); }
public void SetPlayerControlActions(PlayerControlActions action) { if (menuInputHandler != null) { menuInputHandler.DestroyPlayerAction(); } if (action != null) { menuInputHandler = new DefaultMenuInputHandler(action); } OnPlayerActionChanged(action); }
void Awake() { forward = Camera.main.transform.forward; forward.y = 0; forward.Normalize(); right = Quaternion.Euler(new Vector3(0, 90, 0)) * forward; rb = GetComponent <Rigidbody>(); playerInput = GetComponent <MenuInputHandler>(); playerController = GetComponent <MenuPlayerController>(); minInput = playerController.GetMinInput(); buildUpRot = playerController.GetBuildUpRot(); originalY = transform.position.y; }
private void Awake() { menuInputHandler = GetComponent <MenuInputHandler>(); }
private void OnDestroy() { instance = null; Save(); }