Ejemplo n.º 1
0
        // Private Methods

        private void CreateText(GameObject prefab, ref Text textComponent, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset)
        {
            if (prefab == null || content == null)
            {
                return;
            }
            if (textComponent != null)
            {
                Debug.LogError("Window already has " + name + "!");
                return;
            }

            GameObject instance = UITools.InstantiateGUIObject <Text>(
                prefab,
                content.transform,
                name,
                pivot,
                anchor.min,
                anchor.max,
                offset
                );

            if (instance == null)
            {
                return;
            }
            textComponent = instance.GetComponent <Text>();
        }
Ejemplo n.º 2
0
        private GameObject CreateButton(
            GameObject prefab,
            string name,
            UIAnchor anchor,
            UIPivot pivot,
            Vector2 offset,
            out ButtonInfo buttonInfo)
        {
            buttonInfo = (ButtonInfo)null;
            if (Object.op_Equality((Object)prefab, (Object)null))
            {
                return((GameObject)null);
            }
            GameObject gameObject = UITools.InstantiateGUIObject <ButtonInfo>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);

            if (Object.op_Equality((Object)gameObject, (Object)null))
            {
                return((GameObject)null);
            }
            buttonInfo = (ButtonInfo)gameObject.GetComponent <ButtonInfo>();
            if (Object.op_Equality((Object)gameObject.GetComponent <Button>(), (Object)null))
            {
                Debug.Log((object)"Button prefab is missing Button component!");
                return((GameObject)null);
            }
            if (!Object.op_Equality((Object)buttonInfo, (Object)null))
            {
                return(gameObject);
            }
            Debug.Log((object)"Button prefab is missing ButtonInfo component!");
            return((GameObject)null);
        }
Ejemplo n.º 3
0
        // Token: 0x060031F0 RID: 12784 RVA: 0x00146AB4 File Offset: 0x00144CB4
        private GameObject CreateButton(GameObject prefab, string name, 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>();
            if (gameObject.GetComponent <Button>() == null)
            {
                Debug.Log("Button prefab is missing Button component!");
                return(null);
            }
            if (buttonInfo == null)
            {
                Debug.Log("Button prefab is missing ButtonInfo component!");
                return(null);
            }
            return(gameObject);
        }
Ejemplo n.º 4
0
 private void CreateText(
     GameObject prefab,
     ref Text textComponent,
     string name,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset)
 {
     if (Object.op_Equality((Object)prefab, (Object)null) || Object.op_Equality((Object)this.content, (Object)null))
     {
         return;
     }
     if (Object.op_Inequality((Object)textComponent, (Object)null))
     {
         Debug.LogError((object)("Window already has " + name + "!"));
     }
     else
     {
         GameObject gameObject = UITools.InstantiateGUIObject <Text>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);
         if (Object.op_Equality((Object)gameObject, (Object)null))
         {
             return;
         }
         textComponent = (Text)gameObject.GetComponent <Text>();
     }
 }
Ejemplo n.º 5
0
 // Token: 0x060031EF RID: 12783 RVA: 0x00146A64 File Offset: 0x00144C64
 private void CreateImage(GameObject prefab, string name, UIPivot pivot, UIAnchor anchor, Vector2 offset)
 {
     if (!(prefab == null) && !(this.content == null))
     {
         UITools.InstantiateGUIObject <Image>(prefab, this.content.transform, name, pivot, anchor.min, anchor.max, offset);
         return;
     }
 }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
 private void CreateImage(
     GameObject prefab,
     string name,
     UIPivot pivot,
     UIAnchor anchor,
     Vector2 offset)
 {
     if (Object.op_Equality((Object)prefab, (Object)null) || Object.op_Equality((Object)this.content, (Object)null))
     {
         return;
     }
     UITools.InstantiateGUIObject <Image>(prefab, this.content.get_transform(), name, UIPivot.op_Implicit(pivot), (Vector2)anchor.min, (Vector2)anchor.max, offset);
 }
Ejemplo n.º 8
0
        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>();
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
 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();
     }
 }