Exemplo n.º 1
0
 private void OnEnable()
 {
     if (mapping.type == AxisMapping.MappingType.NamedAxis)
     {
         m_SteerAxis = new IKD_CrossPlatformInputManager.VirtualAxis(mapping.axisName);
         IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_SteerAxis);
     }
 }
Exemplo n.º 2
0
            void OnDisable()
            {
                if (IKD_CrossPlatformInputManager.AxisExists(horizontalAxisName))
                {
                    IKD_CrossPlatformInputManager.UnRegisterVirtualAxis(horizontalAxisName);
                }

                if (IKD_CrossPlatformInputManager.AxisExists(verticalAxisName))
                {
                    IKD_CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxisName);
                }
            }
Exemplo n.º 3
0
 void OnEnable()
 {
     if (!IKD_CrossPlatformInputManager.AxisExists(axisName))
     {
         // if the axis doesnt exist create a new one in cross platform input
         m_Axis = new IKD_CrossPlatformInputManager.VirtualAxis(axisName);
         IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
     }
     else
     {
         m_Axis = IKD_CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
     FindPairedButton();
 }
Exemplo n.º 4
0
        IKD_CrossPlatformInputManager.VirtualAxis m_HorizontalVirtualAxis;         // Reference to the joystick in the cross platform input

        void Start()
        {
            wheelBeingHeld = false;
            wheelAngle     = 0f;
            wheelCenter    = GetCenter(steeringWheel.rectTransform);
            wheelPosition  = new Rect(wheelCenter.x - (steeringWheel.rectTransform.sizeDelta.x / 2), wheelCenter.y, steeringWheel.rectTransform.sizeDelta.x, steeringWheel.rectTransform.sizeDelta.y);
            if (!IKD_CrossPlatformInputManager.AxisExists(axisName))
            {
                // if the axis doesnt exist create a new one in cross platform input
                m_HorizontalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(axisName);
                IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
            }
            else
            {
                m_HorizontalVirtualAxis = IKD_CrossPlatformInputManager.VirtualAxisReference(axisName);
            }
        }
Exemplo n.º 5
0
            void CreateVirtualAxes()
            {
                // set axes to use
                m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal);
                m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical);

                // create new axes based on axes to use
                if (m_UseX)
                {
                    m_HorizontalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                    IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
                }
                if (m_UseY)
                {
                    m_VerticalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                    IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
                }
            }
Exemplo n.º 6
0
        private void Update()
        {
            float angle = 0;

            if (Input.acceleration != Vector3.zero)
            {
                switch (tiltAroundAxis)
                {
                case AxisOptions.ForwardAxis:
                    angle = Mathf.Atan2(Input.acceleration.x, -Input.acceleration.y) * Mathf.Rad2Deg +
                            centreAngleOffset;
                    break;

                case AxisOptions.SidewaysAxis:
                    angle = Mathf.Atan2(Input.acceleration.z, -Input.acceleration.y) * Mathf.Rad2Deg +
                            centreAngleOffset;
                    break;
                }
            }

            float axisValue = Mathf.InverseLerp(-fullTiltAngle, fullTiltAngle, angle) * 2 - 1;

            switch (mapping.type)
            {
            case AxisMapping.MappingType.NamedAxis:
                m_SteerAxis.Update(axisValue);
                break;

            case AxisMapping.MappingType.MousePositionX:
                IKD_CrossPlatformInputManager.SetVirtualMousePositionX(axisValue * Screen.width);
                break;

            case AxisMapping.MappingType.MousePositionY:
                IKD_CrossPlatformInputManager.SetVirtualMousePositionY(axisValue * Screen.width);
                break;

            case AxisMapping.MappingType.MousePositionZ:
                IKD_CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue * Screen.width);
                break;
            }
        }
Exemplo n.º 7
0
        void CreateVirtualAxes()
        {
            // set axes to use
            m_UseX = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyHorizontal);
            m_UseY = (axesToUse == AxisOption.Both || axesToUse == AxisOption.OnlyVertical);

            // create new axes based on axes to use
            if (m_UseX)
            {
                //	m_HorizontalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                //	IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
                if (!IKD_CrossPlatformInputManager.AxisExists(horizontalAxisName))
                {
                    // if the axis doesnt exist create a new one in cross platform input
                    m_HorizontalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                    IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
                }
                else
                {
                    m_HorizontalVirtualAxis = IKD_CrossPlatformInputManager.VirtualAxisReference(horizontalAxisName);
                }
            }
            if (m_UseY)
            {
                //m_VerticalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                //IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
                if (!IKD_CrossPlatformInputManager.AxisExists(verticalAxisName))
                {
                    // if the axis doesnt exist create a new one in cross platform input
                    m_VerticalVirtualAxis = new IKD_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                    IKD_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
                }
                else
                {
                    m_VerticalVirtualAxis = IKD_CrossPlatformInputManager.VirtualAxisReference(verticalAxisName);
                }
            }
        }
Exemplo n.º 8
0
 private void AddButton(string name)
 {
     // we have not registered this button yet so add it, happens in the constructor
     IKD_CrossPlatformInputManager.RegisterVirtualButton(new IKD_CrossPlatformInputManager.VirtualButton(name));
 }
Exemplo n.º 9
0
 public void SetDownState()
 {
     IKD_CrossPlatformInputManager.SetButtonDown(Name);
 }
Exemplo n.º 10
0
 public void SetAxisNegativeState()
 {
     IKD_CrossPlatformInputManager.SetAxisNegative(Name);
 }
Exemplo n.º 11
0
 public void SetAxisNeutralState()
 {
     IKD_CrossPlatformInputManager.SetAxisZero(Name);
 }
Exemplo n.º 12
0
 public void SetUpState()
 {
     IKD_CrossPlatformInputManager.SetButtonUp(Name);
 }
Exemplo n.º 13
0
 public void HandleInput(float value)
 {
     IKD_CrossPlatformInputManager.SetAxis(axis, (value * 2f) - 1f);
 }