# Unity script error (620662)

**URL:** https://discussions.unity.com/t/unity-script-error-620662/620662
**Category:** Scripting
**Tags:** Scripting
**Created:** [March 17, 2016, 4:48am UTC](https://discussions.unity.com/t/unity-script-error-620662/620662 "2016-03-17T04:48:20Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![halojman](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/halojman/32/455667_2.png) [@halojman](https://discussions.unity.com/u/halojman)
#### Post date: [March 17, 2016, 4:48am UTC](https://discussions.unity.com/t/unity-script-error-620662/620662/1 "2016-03-17T04:48:20Z")

</div>

Hi, I’m coding and I’m getting this error:

**Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs(22,56): error CS0117: `UnitySampleAssets.CrossPlatformInput.CrossPlatformInputManager' does not contain a definition for `AxisExists’**

This is my code:

using System;  
using UnityEngine;  
using UnityEngine.EventSystems;  
using UnitySampleAssets.CrossPlatformInput;

namespace UnityStandardAssets.CrossPlatformInput  
{  
public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler  
{  
// designed to work in a pair with another axis touch button  
// (typically with one having -1 and one having 1 axisValues)  
public string axisName = “Horizontal”; // The name of the axis  
public float axisValue = 1; // The axis that the value has  
public float responseSpeed = 3; // The speed at which the axis touch button responds  
public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre

AxisTouchButton m\_PairedWith; // Which button this one is paired with  
CrossPlatformInputManager.VirtualAxis m\_Axis; // A reference to the virtual axis as it is in the cross platform input

void OnEnable()  
{  
if (!CrossPlatformInputManager.AxisExists(axisName))  
{  
// if the axis doesnt exist create a new one in cross platform input  
m\_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);  
CrossPlatformInputManager.RegisterVirtualAxis(m\_Axis);  
}  
else  
{  
m\_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);  
}  
FindPairedButton();  
}

void FindPairedButton()  
{  
// find the other button witch which this button should be paired  
// (it should have the same axisName)  
var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[&nbsp;];

if (otherAxisButtons != null)  
{  
for (int i = 0; i \< otherAxisButtons.Length; i++)  
{  
if (otherAxisButtons\_.axisName == axisName && otherAxisButtons _!= this)_\_  
_\* {\*_  
 _m\_PairedWith = otherAxisButtons\*;  
 \_ }  
  }  
  }  
  }  
  void OnDisable()  
  {  
  // The object is disabled so remove it from the cross platform input system\*  
 \* m\_Axis.Remove();\*  
 \* }  
  public void OnPointerDown(PointerEventData data)  
  {\_  
  if (m\_PairedWith == null)  
 \_ {  
  FindPairedButton();  
  }  
  // update the axis and record that the button has been pressed this frame\*  
  m\_Axis.Update(Mathf.MoveTowards(m\_Axis.GetValue, axisValue, responseSpeed \* Time.deltaTime));  
 \* }  
  public void OnPointerUp(PointerEventData data)  
  {  
  m\_Axis.Update(Mathf.MoveTowards(m\_Axis.GetValue, 0, responseSpeed \* Time.deltaTime));  
  }  
  }  
 }\*  
 Note: It’s from the asset store\__

---

<div class="post-metadata">

### Author: ![LeftyRighty](https://avatars.discourse-cdn.com/v4/letter/l/e19adc/32.png) [@LeftyRighty](https://discussions.unity.com/u/LeftyRighty)
#### Post date: [March 17, 2016, 10:34am UTC](https://discussions.unity.com/t/unity-script-error-620662/620662/2 "2016-03-17T10:34:01Z")

</div>

lets start with [Using code tags properly - Unity Engine - Unity Discussions](http://forum.unity3d.com/threads/using-code-tags-properly.143875/)

as the error says, “AxisExists” doesn’t exist… so you’re likely missing a file somewhere, or the function has been misspelt?

---

<div class="post-metadata">

### Author: ![halojman](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/halojman/32/455667_2.png) [@halojman](https://discussions.unity.com/u/halojman)
#### Post date: [March 17, 2016, 7:25pm UTC](https://discussions.unity.com/t/unity-script-error-620662/620662/3 "2016-03-17T19:25:13Z")

</div>

```javascript
using System;
using UnityEngine;
using UnityEngine.EventSystems;
using UnitySampleAssets.CrossPlatformInput;

namespace UnityStandardAssets.CrossPlatformInput
{
    public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
    {
        // designed to work in a pair with another axis touch button
        // (typically with one having -1 and one having 1 axisValues)
        public string axisName = "Horizontal"; // The name of the axis
        public float axisValue = 1; // The axis that the value has
        public float responseSpeed = 3; // The speed at which the axis touch button responds
        public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre

        AxisTouchButton m_PairedWith; // Which button this one is paired with
        CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input

        void OnEnable()
        {
            if (!CrossPlatformInputManager.AxisExsists(axisName))
            {
                // if the axis doesnt exist create a new one in cross platform input
                m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);
                CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
            }
            else
            {
                m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
            }
            FindPairedButton();
        }

        void FindPairedButton()
        {
            // find the other button witch which this button should be paired
            // (it should have the same axisName)
            var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[];

            if (otherAxisButtons != null)
            {
                for (int i = 0; i < otherAxisButtons.Length; i++)
                {
                    if (otherAxisButtons[i].axisName == axisName && otherAxisButtons[i] != this)
                    {
                        m_PairedWith = otherAxisButtons[i];
                    }
                }
            }
        }

        void OnDisable()
        {
            // The object is disabled so remove it from the cross platform input system
            m_Axis.Remove();
        }

        public void OnPointerDown(PointerEventData data)
        {
            if (m_PairedWith == null)
            {
                FindPairedButton();
            }
            // update the axis and record that the button has been pressed this frame
            m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, axisValue, responseSpeed * Time.deltaTime));
        }

        public void OnPointerUp(PointerEventData data)
        {
            m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, 0, responseSpeed * Time.deltaTime));
        }
    }
}

```
