private bool ContainsController(Rewired.Player p) { foreach (var controller in activeControllers) { if (controller.ControllerNumber == p.id) return true; } return false; }
private void AddController(Rewired.Player p) { print("add player"); MultiplayerUIController controller = Instantiate(controllerPrefab); controller.ControllerNumber = p.id; controller.ChangeSelected(firstSelected); activeControllers.Add(controller); }
private void RemoveController(Rewired.Player p) { for (int i = 0; i < activeControllers.Count; i++) { if (activeControllers[i].ControllerNumber == p.id) { Destroy(activeControllers[i].gameObject); activeControllers.RemoveAt(i); } } }
private void ClearJoystickCalibrationMapXml(Rewired.Joystick joystick) { string text = "UserRemapping_v3"; text += "&dataType=CalibrationMap"; text = text + "&controllerType=" + joystick.type.ToString(); text = text + "&hardwareIdentifier=" + joystick.hardwareIdentifier; text = text + "&hardwareGuid=" + joystick.hardwareTypeGuid.ToString(); if (PlayerPrefs.HasKey(text)) { PlayerPrefs.DeleteKey(text); } }
private string GetJoystickCalibrationMapXml(Rewired.Joystick joystick) { string text = "UserRemapping_v3"; text += "&dataType=CalibrationMap"; text = text + "&controllerType=" + joystick.type.ToString(); text = text + "&hardwareIdentifier=" + joystick.hardwareIdentifier; text = text + "&hardwareGuid=" + joystick.hardwareTypeGuid.ToString(); if (!PlayerPrefs.HasKey(text)) { return string.Empty; } return PlayerPrefs.GetString(text); }
private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { if (prefab == null || this.content == null) { return; } if (textComponent != null) { UnityEngine.Debug.LogError("Window already has " + name + "!"); return; } GameObject gameObject = UITools.InstantiateGUIObject<Text>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); if (gameObject == null) { return; } textComponent = gameObject.GetComponent<Text>(); }
public Calibration(Player player, Rewired.Joystick joystick, CalibrationMap calibrationMap) : base(ControlRemappingDemo1.QueueActionType.Calibrate) { this.player = player; this.joystick = joystick; this.calibrationMap = calibrationMap; this.selectedElementIdentifierId = -1; }
private GameObject CreateButton(GameObject prefab, string name, Rewired.UI.UIAnchor anchor, UIPivot pivot, Vector2 offset, out ButtonInfo buttonInfo) { buttonInfo = null; if (prefab == null) { return null; } GameObject gameObject = UITools.InstantiateGUIObject<ButtonInfo>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); if (gameObject == null) { return null; } buttonInfo = gameObject.GetComponent<ButtonInfo>(); UnityEngine.UI.Button component = gameObject.GetComponent<UnityEngine.UI.Button>(); if (component == null) { UnityEngine.Debug.Log("Button prefab is missing Button component!"); return null; } if (buttonInfo == null) { UnityEngine.Debug.Log("Button prefab is missing ButtonInfo component!"); return null; } return gameObject; }
private void CreateImage(GameObject prefab, string name, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { if (prefab == null || this.content == null) { return; } UITools.InstantiateGUIObject<Image>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset); }
public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string text) { this.AddContentText(prefab, pivot, anchor, offset); this.SetContentText(text, this._contentText.Count - 1); }
public void CreateButton(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string buttonText, UnityAction confirmCallback, UnityAction cancelCallback, bool setDefault) { if (prefab == null) { return; } ButtonInfo buttonInfo; GameObject gameObject = this.CreateButton(prefab, "Button", anchor, pivot, offset, out buttonInfo); if (gameObject == null) { return; } UnityEngine.UI.Button component = gameObject.GetComponent<UnityEngine.UI.Button>(); if (confirmCallback != null) { component.onClick.AddListener(confirmCallback); } CustomButton customButton = component as CustomButton; if (cancelCallback != null && customButton != null) { customButton.CancelEvent += cancelCallback; } if (buttonInfo.text != null) { buttonInfo.text.text = buttonText; } if (setDefault) { this._defaultUIElement = gameObject; } }
public void AddContentText(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { Text item = null; this.CreateText(prefab, ref item, "Content Text", pivot, anchor, offset); this._contentText.Add(item); }
public void AddContentImage(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset, string text) { this.AddContentImage(prefab, pivot, anchor, offset); }
public void AddContentImage(GameObject prefab, UIPivot pivot, Rewired.UI.UIAnchor anchor, Vector2 offset) { this.CreateImage(prefab, "Image", pivot, anchor, offset); }
private void SaveJoystickCalibrationData(Rewired.Joystick joystick) { if (joystick == null) { return; } JoystickCalibrationMapSaveData calibrationMapSaveData = joystick.GetCalibrationMapSaveData(); string joystickCalibrationMapPlayerPrefsKey = this.GetJoystickCalibrationMapPlayerPrefsKey(calibrationMapSaveData); PlayerPrefs.SetString(joystickCalibrationMapPlayerPrefsKey, calibrationMapSaveData.map.ToXmlString()); }
private void LoadJoystickCalibrationData(Rewired.Joystick joystick) { if (joystick == null) { return; } joystick.ImportCalibrationMapFromXmlString(this.GetJoystickCalibrationMapXml(joystick)); }