Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity script error

Discussion in 'Scripting' started by halojman, Mar 17, 2016.

  1. halojman

    halojman

    Joined:
    Sep 28, 2015
    Posts:
    27
    I'm currently working on a project, But I've ran into an error. I have no clue how to fix it, these are my errors:

    Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs(3,19): error CS0234: The type or namespace name `EventSystems' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs(7,55): error CS0246: The type or namespace name `IPointerDownHandler' could not be found. Are you missing a using directive or an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/AxisTouchButton.cs(7,76): error CS0246: The type or namespace name `IPointerUpHandler' could not be found. Are you missing a using directive or an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs(3,19): error CS0234: The type or namespace name `EventSystems' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?


    Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs(7,48): error CS0246: The type or namespace name `IPointerDownHandler' could not be found. Are you missing a using directive or an assembly reference?


    Assets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs(7,69): error CS0246: The type or namespace name `IPointerUpHandler' could not be found. Are you missing a using directive or an assembly reference?


    ssets/Standard Assets/CrossPlatformInput/Scripts/Joystick.cs(7,88): error CS0246: The type or namespace name `IDragHandler' could not be found. Are you missing a using directive or an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs(3,19): error CS0234: The type or namespace name `EventSystems' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs(4,19): error CS0234: The type or namespace name `UI' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs(9,48): error CS0246: The type or namespace name `IPointerDownHandler' could not be found. Are you missing a using directive or an assembly reference?


    Assets/Standard Assets/CrossPlatformInput/Scripts/TouchPad.cs(9,69): error CS0246: The type or namespace name `IPointerUpHandler' could not be found. Are you missing a using directive or an assembly reference?


    Assets/Standard Assets/Utility/EventSystemChecker.cs(4,19): error CS0234: The type or namespace name `EventSystems' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?

    Assets/Standard Assets/Utility/FPSCounter.cs(3,19): error CS0234: The type or namespace name `UI' does not exist in the namespace `UnityEngine'. Are you missing an assembly reference?


    My Script is:

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.EventSystems;
    4.  
    5. namespace UnityStandardAssets.CrossPlatformInput
    6. {
    7.     public class AxisTouchButton : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
    8.     {
    9.         // designed to work in a pair with another axis touch button
    10.         // (typically with one having -1 and one having 1 axisValues)
    11.         public string axisName = "Horizontal"; // The name of the axis
    12.         public float axisValue = 1; // The axis that the value has
    13.         public float responseSpeed = 3; // The speed at which the axis touch button responds
    14.         public float returnToCentreSpeed = 3; // The speed at which the button will return to its centre
    15.  
    16.         AxisTouchButton m_PairedWith; // Which button this one is paired with
    17.         CrossPlatformInputManager.VirtualAxis m_Axis; // A reference to the virtual axis as it is in the cross platform input
    18.  
    19.         void OnEnable()
    20.         {
    21.             if (!CrossPlatformInputManager.AxisExists(axisName))
    22.             {
    23.                 // if the axis doesnt exist create a new one in cross platform input
    24.                 m_Axis = new CrossPlatformInputManager.VirtualAxis(axisName);
    25.                 CrossPlatformInputManager.RegisterVirtualAxis(m_Axis);
    26.             }
    27.             else
    28.             {
    29.                 m_Axis = CrossPlatformInputManager.VirtualAxisReference(axisName);
    30.             }
    31.             FindPairedButton();
    32.         }
    33.  
    34.         void FindPairedButton()
    35.         {
    36.             // find the other button witch which this button should be paired
    37.             // (it should have the same axisName)
    38.             var otherAxisButtons = FindObjectsOfType(typeof(AxisTouchButton)) as AxisTouchButton[];
    39.  
    40.             if (otherAxisButtons != null)
    41.             {
    42.                 for (int i = 0; i < otherAxisButtons.Length; i++)
    43.                 {
    44.                     if (otherAxisButtons[i].axisName == axisName && otherAxisButtons[i] != this)
    45.                     {
    46.                         m_PairedWith = otherAxisButtons[i];
    47.                     }
    48.                 }
    49.             }
    50.         }
    51.  
    52.         void OnDisable()
    53.         {
    54.             // The object is disabled so remove it from the cross platform input system
    55.             m_Axis.Remove();
    56.         }
    57.  
    58.  
    59.         public void OnPointerDown(PointerEventDat data)
    60.         {
    61.             if (m_PairedWith == null)
    62.             {
    63.                 FindPairedButton();
    64.             }
    65.             // update the axis and record that the button has been pressed this frame
    66.             m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, axisValue, responseSpeed * Time.deltaTime));
    67.         }
    68.  
    69.  
    70.         public void OnPointerUp(PointerEventData data)
    71.         {
    72.             m_Axis.Update(Mathf.MoveTowards(m_Axis.GetValue, 0, responseSpeed * Time.deltaTime));
    73.         }
    74.     }
    75. }
    Can someone help me fix the errors, and explain what they are?
     
  2. alexzzzz

    alexzzzz

    Joined:
    Nov 20, 2010
    Posts:
    1,447
    I would guess that your project doesn't reference UnityEngine.UI.dll.
     
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This. What version of Unity are you using?
     
  4. Abhiroop-Tandon

    Abhiroop-Tandon

    Joined:
    Oct 2, 2014
    Posts:
    3
    I am having the same issue and i am using Unity5.4.1
    how did you fix it ??
     
  5. Vedrit

    Vedrit

    Joined:
    Feb 8, 2013
    Posts:
    514
    Include
    Code (csharp):
    1. using UnityEngine.UI;
    in your script, if I understand correctly
     
  6. Abhiroop-Tandon

    Abhiroop-Tandon

    Joined:
    Oct 2, 2014
    Posts:
    3
    Closing unity and opening it again fixed for me hahaha. Thanks for the reply though, i'll try it next time i get them. It was only coming when i was building the project