public GUILabel(GameObject gameObject) { if (gameObject == null) { Debug.LogError("Rewired Control Mapper: gameObject is null!"); return; } text = UnityTools.GetComponentInSelfOrChildren <Text>(gameObject); Check(); }
public void SetJoystick(int playerId, Joystick joystick) { if (!base.initialized) { return; } this.playerId = playerId; this.joystick = joystick; if (joystick == null) { Debug.LogError("Rewired Control Mapper: Joystick cannot be null!"); return; } float num = 0f; for (int i = 0; i < joystick.axisCount; i++) { int index = i; GameObject gameObject = UITools.InstantiateGUIObject <Button>(this.axisButtonPrefab, this.axisScrollAreaContent, "Axis" + i); Button button = gameObject.GetComponent <Button>(); button.onClick.AddListener(delegate { this.OnAxisSelected(index, button); }); Text componentInSelfOrChildren = UnityTools.GetComponentInSelfOrChildren <Text>(gameObject); if (componentInSelfOrChildren != null) { componentInSelfOrChildren.text = joystick.AxisElementIdentifiers[i].name; } if (num == 0f) { num = UnityTools.GetComponentInSelfOrChildren <LayoutElement>(gameObject).minHeight; } this.axisButtons.Add(button); } float spacing = this.axisScrollAreaContent.GetComponent <VerticalLayoutGroup>().spacing; this.axisScrollAreaContent.sizeDelta = new Vector2(this.axisScrollAreaContent.sizeDelta.x, Mathf.Max((float)joystick.axisCount * (num + spacing) - spacing, this.axisScrollAreaContent.sizeDelta.y)); this.origCalibrationData = joystick.calibrationMap.ToXmlString(); this.displayAreaWidth = this.rightContentContainer.sizeDelta.x; this.rewiredStandaloneInputModule = base.gameObject.transform.root.GetComponentInChildren <RewiredStandaloneInputModule>(); if (this.rewiredStandaloneInputModule != null) { this.menuHorizActionId = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.horizontalAxis); this.menuVertActionId = ReInput.mapping.GetActionId(this.rewiredStandaloneInputModule.verticalAxis); } if (joystick.axisCount > 0) { this.SelectAxis(0); } base.defaultUIElement = this.doneButton.gameObject; this.RefreshControls(); this.Redraw(); }
public GUIElement(GameObject gameObject) { if (gameObject == null) { Debug.LogError("Rewired Control Mapper: gameObject is null!"); return; } this.selectable = gameObject.GetComponent <Selectable>(); if (selectable == null) { Debug.LogError("Rewired Control Mapper: Selectable is null!"); return; } this.gameObject = gameObject; this.rectTransform = gameObject.GetComponent <RectTransform>(); text = UnityTools.GetComponentInSelfOrChildren <Text>(gameObject); this.uiElementInfo = gameObject.GetComponent <UIElementInfo>(); children = new List <GUIElement>(); }
public void SetJoystick(int playerId, Joystick joystick) { if (!initialized) { return; } this.playerId = playerId; this.joystick = joystick; if (joystick == null) { Debug.LogError("Rewired Control Mapper: Joystick cannot be null!"); return; } // Create axis list float buttonHeight = 0.0f; for (int i = 0; i < joystick.axisCount; i++) { int index = i; GameObject instance = UITools.InstantiateGUIObject <Button>(axisButtonPrefab, axisScrollAreaContent, "Axis" + i); Button button = instance.GetComponent <Button>(); button.onClick.AddListener(() => { OnAxisSelected(index, button); }); Text text = UnityTools.GetComponentInSelfOrChildren <Text>(instance); if (text != null) { text.text = joystick.AxisElementIdentifiers[i].name; } if (buttonHeight == 0.0f) { buttonHeight = UnityTools.GetComponentInSelfOrChildren <LayoutElement>(instance).minHeight; } axisButtons.Add(button); } // set axis list height float vSpacing = axisScrollAreaContent.GetComponent <VerticalLayoutGroup>().spacing; axisScrollAreaContent.sizeDelta = new Vector2(axisScrollAreaContent.sizeDelta.x, Mathf.Max((joystick.axisCount * (buttonHeight + vSpacing) - vSpacing), axisScrollAreaContent.sizeDelta.y)); // Store the original calibration data so we can revert origCalibrationData = joystick.calibrationMap.ToXmlString(); // Record info displayAreaWidth = rightContentContainer.sizeDelta.x; // Try to get the UI control axis deadzone from the RewiredStandaloneInputModule if it exists in the hierarchy // This is used to prevent users from rendering menu navigation axes unusable by changing the axis sensitivity rewiredStandaloneInputModule = gameObject.transform.root.GetComponentInChildren <RewiredStandaloneInputModule>(); if (rewiredStandaloneInputModule != null) { menuHorizActionId = ReInput.mapping.GetActionId(rewiredStandaloneInputModule.horizontalAxis); menuVertActionId = ReInput.mapping.GetActionId(rewiredStandaloneInputModule.verticalAxis); } // Select first axis if (joystick.axisCount > 0) { SelectAxis(0); } // Set default UI element defaultUIElement = doneButton.gameObject; // Draw window RefreshControls(); Redraw(); }
public void SetJoystick(int playerId, Joystick joystick) { if (!this.initialized) { return; } this.playerId = playerId; this.joystick = joystick; if (joystick == null) { Debug.LogError((object)"Rewired Control Mapper: Joystick cannot be null!"); } else { float num = 0.0f; for (int index = 0; index < ((ControllerWithAxes)joystick).get_axisCount(); ++index) { // ISSUE: object of a compiler-generated type is created // ISSUE: variable of a compiler-generated type CalibrationWindow.\u003CSetJoystick\u003Ec__AnonStorey0 joystickCAnonStorey0 = new CalibrationWindow.\u003CSetJoystick\u003Ec__AnonStorey0(); // ISSUE: reference to a compiler-generated field joystickCAnonStorey0.\u0024this = this; // ISSUE: reference to a compiler-generated field joystickCAnonStorey0.index = index; GameObject gameObject = UITools.InstantiateGUIObject <Button>(this.axisButtonPrefab, (Transform)this.axisScrollAreaContent, "Axis" + (object)index); // ISSUE: reference to a compiler-generated field joystickCAnonStorey0.button = (Button)gameObject.GetComponent <Button>(); // ISSUE: reference to a compiler-generated field // ISSUE: method pointer ((UnityEvent)joystickCAnonStorey0.button.get_onClick()).AddListener(new UnityAction((object)joystickCAnonStorey0, __methodptr(\u003C\u003Em__0))); Text inSelfOrChildren = (Text)UnityTools.GetComponentInSelfOrChildren <Text>(gameObject); if (Object.op_Inequality((Object)inSelfOrChildren, (Object)null)) { inSelfOrChildren.set_text(((ControllerWithAxes)joystick).get_AxisElementIdentifiers()[index].get_name()); } if ((double)num == 0.0) { num = ((LayoutElement)UnityTools.GetComponentInSelfOrChildren <LayoutElement>(gameObject)).get_minHeight(); } // ISSUE: reference to a compiler-generated field this.axisButtons.Add(joystickCAnonStorey0.button); } float spacing = ((HorizontalOrVerticalLayoutGroup)((Component)this.axisScrollAreaContent).GetComponent <VerticalLayoutGroup>()).get_spacing(); this.axisScrollAreaContent.set_sizeDelta(new Vector2((float)this.axisScrollAreaContent.get_sizeDelta().x, Mathf.Max((float)((ControllerWithAxes)joystick).get_axisCount() * (num + spacing) - spacing, (float)this.axisScrollAreaContent.get_sizeDelta().y))); this.origCalibrationData = ((ControllerWithAxes)joystick).get_calibrationMap().ToXmlString(); this.displayAreaWidth = (float)this.rightContentContainer.get_sizeDelta().x; this.rewiredStandaloneInputModule = (RewiredStandaloneInputModule)((Component)((Component)this).get_gameObject().get_transform().get_root()).GetComponentInChildren <RewiredStandaloneInputModule>(); if (Object.op_Inequality((Object)this.rewiredStandaloneInputModule, (Object)null)) { this.menuHorizActionId = ReInput.get_mapping().GetActionId(this.rewiredStandaloneInputModule.horizontalAxis); this.menuVertActionId = ReInput.get_mapping().GetActionId(this.rewiredStandaloneInputModule.verticalAxis); } if (((ControllerWithAxes)joystick).get_axisCount() > 0) { this.SelectAxis(0); } this.defaultUIElement = ((Component)this.doneButton).get_gameObject(); this.RefreshControls(); this.Redraw(); } }