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

            if (RG_CrossPlatformInputManager.AxisExists(verticalAxisName))
            {
                RG_CrossPlatformInputManager.UnRegisterVirtualAxis(verticalAxisName);
            }
        }
Esempio n. 3
0
 void OnEnable()
 {
     if (!RG_CrossPlatformInputManager.AxisExists(axisName))
     {
         // if the axis doesnt exist create a new one in cross platform input
         m_Axis = new RG_CrossPlatformInputManager.VirtualAxis(axisName);
         RG_CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
     }
     else
     {
         m_Axis = RG_CrossPlatformInputManager.VirtualAxisReference(axisName);
     }
     FindPairedButton();
 }
Esempio n. 4
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 RG_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                RG_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
            }
            if (m_UseY)
            {
                m_VerticalVirtualAxis = new RG_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                RG_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
            }
        }
Esempio n. 5
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:
                RG_CrossPlatformInputManager.SetVirtualMousePositionX(axisValue * Screen.width);
                break;

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

            case AxisMapping.MappingType.MousePositionZ:
                RG_CrossPlatformInputManager.SetVirtualMousePositionZ(axisValue * Screen.width);
                break;
            }
        }
Esempio n. 6
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 RG_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                //	RG_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
                if (!RG_CrossPlatformInputManager.AxisExists(horizontalAxisName))
                {
                    // if the axis doesnt exist create a new one in cross platform input
                    m_HorizontalVirtualAxis = new RG_CrossPlatformInputManager.VirtualAxis(horizontalAxisName);
                    RG_CrossPlatformInputManager.RegisterVirtualAxis(m_HorizontalVirtualAxis);
                }
                else
                {
                    m_HorizontalVirtualAxis = RG_CrossPlatformInputManager.VirtualAxisReference(horizontalAxisName);
                }
            }
            if (m_UseY)
            {
                //m_VerticalVirtualAxis = new RG_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                //RG_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
                if (!RG_CrossPlatformInputManager.AxisExists(verticalAxisName))
                {
                    // if the axis doesnt exist create a new one in cross platform input
                    m_VerticalVirtualAxis = new RG_CrossPlatformInputManager.VirtualAxis(verticalAxisName);
                    RG_CrossPlatformInputManager.RegisterVirtualAxis(m_VerticalVirtualAxis);
                }
                else
                {
                    m_VerticalVirtualAxis = RG_CrossPlatformInputManager.VirtualAxisReference(verticalAxisName);
                }
            }
        }
Esempio n. 7
0
 private void AddButton(string name)
 {
     // we have not registered this button yet so add it, happens in the constructor
     RG_CrossPlatformInputManager.RegisterVirtualButton(new RG_CrossPlatformInputManager.VirtualButton(name));
 }
 public void HandleInput(float value)
 {
     RG_CrossPlatformInputManager.SetAxis(axis, (value * 2f) - 1f);
 }
Esempio n. 9
0
 public void SetDownState()
 {
     RG_CrossPlatformInputManager.SetButtonDown(Name);
 }
Esempio n. 10
0
 public void SetAxisNegativeState()
 {
     RG_CrossPlatformInputManager.SetAxisNegative(Name);
 }
Esempio n. 11
0
 public void SetAxisNeutralState()
 {
     RG_CrossPlatformInputManager.SetAxisZero(Name);
 }
Esempio n. 12
0
 public void SetUpState()
 {
     RG_CrossPlatformInputManager.SetButtonUp(Name);
 }