Beispiel #1
0
        private void Awake()
        {
            xAxis      = new SimpleInput.AxisInput("Horizontal" + suffix);
            yAxis      = new SimpleInput.AxisInput("Vertical" + suffix);
            joystickTR = (RectTransform)transform;
            thumbTR    = thumb.rectTransform;

            Image bgImage = GetComponent <Image>();

            if (bgImage != null)
            {
                background = bgImage;
                background.raycastTarget = false;
            }

            if (isDynamicJoystick)
            {
                opacity             = 0f;
                thumb.raycastTarget = false;

                OnUpdate();
            }
            else
            {
                opacity             = 1.0f;
                thumb.raycastTarget = true;
            }
            _1OverMovementAreaRadius = 1f / movementAreaRadius;
            movementAreaRadiusSqr    = movementAreaRadius * movementAreaRadius;
        }
        private void Awake()
        {
            if (axes.Length > 0)
            {
                axisInputs = new SimpleInput.AxisInput[axes.Length];

                int index = 0;
                for (int i = 0; i < axisInputs.Length; i++)
                {
                    try
                    {
                        SimpleInput.AxisInput unityAxis = new SimpleInput.AxisInput(axes[i])
                        {
                            value = Input.GetAxisRaw(axes[i])
                        };
                        axisInputs[index++] = unityAxis;
                    }
                    catch { }
                }

                if (index < axisInputs.Length)
                {
                    Array.Resize(ref axisInputs, index);
                }
            }

            if (buttons.Length > 0)
            {
                buttonInputs = new SimpleInput.ButtonInput[buttons.Length];

                int index = 0;
                for (int i = 0; i < buttonInputs.Length; i++)
                {
                    try
                    {
                        SimpleInput.ButtonInput unityButton = new SimpleInput.ButtonInput(buttons[i])
                        {
                            value = Input.GetButton(buttons[i])
                        };
                        buttonInputs[index++] = unityButton;
                    }
                    catch { }
                }

                if (index < buttonInputs.Length)
                {
                    Array.Resize(ref buttonInputs, index);
                }
            }

            if (mouseButtons.Length > 0)
            {
                mouseButtonInputs = new SimpleInput.MouseButtonInput[mouseButtons.Length];

                int index = 0;
                for (int i = 0; i < mouseButtonInputs.Length; i++)
                {
                    try
                    {
                        SimpleInput.MouseButtonInput unityMouseButton = new SimpleInput.MouseButtonInput(mouseButtons[i])
                        {
                            value = Input.GetMouseButton(mouseButtons[i])
                        };
                        mouseButtonInputs[index++] = unityMouseButton;
                    }
                    catch { }
                }

                if (index < mouseButtonInputs.Length)
                {
                    Array.Resize(ref mouseButtonInputs, index);
                }
            }

            if (keys.Length > 0)
            {
                keyInputs = new SimpleInput.KeyInput[keys.Length];
                for (int i = 0; i < keyInputs.Length; i++)
                {
                    SimpleInput.KeyInput unityKey = new SimpleInput.KeyInput(keys[i])
                    {
                        value = Input.GetKey(keys[i])
                    };
                    keyInputs[i] = unityKey;
                }
            }
        }