Search Unity

Error: are you missing a using directive or an assembly reference?

Discussion in 'Formats & External Tools' started by sreeksuser, Aug 20, 2019.

  1. sreeksuser

    sreeksuser

    Joined:
    Aug 20, 2019
    Posts:
    2
    I installed unity3D, Andriod SDK and JDK. when I imported the: arcore-unity-sdk-v1.11 including examples . I am getting Error.

    This is in Windows10. JDK is 1.8
    unity version-unity2019.2.1f1

    Assets\GoogleARCore\Examples\CloudAnchors\Scripts\AnchorController.cs(40,10): error CS0246: The type or namespace name 'SyncVarAttribute' could not be found (are you missing a using directive or an assembly reference?)
    Assets\GoogleARCore\Examples\CloudAnchors\Scripts\AnchorController.cs(40,10): error CS0246: The type or namespace name 'SyncVarAttribute' could not be found (are you missing a using directive or an assembly reference?)
    Assets\GoogleARCore\Examples\CloudAnchors\Scripts\AnchorController.cs(40,10): error CS0246: The type or namespace name 'SyncVar' could not be found (are you missing a using directive or an assembly reference?)
    Assets\GoogleARCore\Examples\CloudAnchors\Scripts\LocalPlayerController.cs(46,30): error CS0115: 'LocalPlayerController.OnStartLocalPlayer()': no suitable method found to override


    I tried multiple unity versions same error? am I missing anything.
    I
     
  2. RZKsenia

    RZKsenia

    Joined:
    Aug 16, 2019
    Posts:
    1
    I have the same problem (
     
  3. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,277
  4. UrMomDerpThanoFish

    UrMomDerpThanoFish

    Joined:
    Oct 18, 2019
    Posts:
    7
    For me the errors
    Assets\Scripts\Pull.cs(3,21): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)
    and
    Assets\Scripts\Pull.cs(6,12): error CS0246: The type or namespace name 'Rigidbody2D' could not be found (are you missing a using directive or an assembly reference?)
    keeps happening, does anyone know why and how to fix it
     
  5. UrMomDerpThanoFish

    UrMomDerpThanoFish

    Joined:
    Oct 18, 2019
    Posts:
    7
    Im also in the latest version of unity
     
  6. MHeru_Art07

    MHeru_Art07

    Joined:
    Nov 7, 2016
    Posts:
    3
    does anyone found a solution for this problem?
     
  7. AntonKovalchuk

    AntonKovalchuk

    Joined:
    Dec 14, 2019
    Posts:
    2
    For me the errors

    Code (CSharp):
    1. Assets\Scripts\TachLineAnimation.cs(16,51): error CS0246: The type or namespace name 'SprintRenderer' could not be found (are you missing a using directive or an assembly reference?)
    2.  
    3. Assets\Scripts\TachLineAnimation.cs(20,18): error CS0103: The name 'Timer' does not exist in the current context
    4.  
    Unity 2018.4.13
     
  8. nicocalcio300

    nicocalcio300

    Joined:
    Mar 14, 2020
    Posts:
    1
    For me those, anyone can help me?

    1.Assets\TypeOut\Scripts\TypeOutEditor.cs(5,7): error CS0246: The type or namespace name 'UnityEditorInternal' could not be found (are you missing a using directive or an assembly refer
    2.The type or namespace name 'MenuItemAttribute' could not be found (are you missing a using directive or an assembly reference?)
    3.The type or namespace name 'MenuItem' could not be found (are you missing a using directive or an assembly reference?)
    4.The type or namespace name 'Editor' could not be found (are you missing a using directive or an assembly reference?)
    5.The type or namespace name 'CustomEditorAttribute' could not be found (are you missing a using directive or an assembly reference?)
    6.The type or namespace name 'CustomEditor' could not be found (are you missing a using directive or an assembly reference?)
    7.'TypeOutEditor.OnInspectorGUI()': no suitable method found to override
    8.The type or namespace name 'SerializedObject' could not be found (are you missing a using directive or an assembly reference?)
    9.The type or namespace name 'SerializedProperty' could not be found (are you missing a using directive or an assembly reference?)
    10.Error building Player because scripts had compiler errors
     
  9. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It helps to post code. But really, this error is usually user based, you've made a typo or you've made a class that doesn't belong to a unique namespace, or using deprecated code.

    Some people forget to include using at the top, or even :Monobehaviour (derive from a Unity class).

    Lots of reasons but usually it'll be the developer hasn't linked their code up properly.
     
  10. chcebycnayt

    chcebycnayt

    Joined:
    Mar 22, 2020
    Posts:
    1
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3.  
    4. [RequireComponent(typeof(PlayerMotor))]
    5.  
    6. public class PlayerController : MonoBehaviour
    7.  
    8.    
    9.  
    10. {
    11.     [SerializeField]
    12.     private float speed = 5f;
    13.  
    14.     private PlayerMotor motor;
    15.  
    16.     void start ()
    17.     {
    18.         motor = GetComponent<PlayerMotor>();
    19.     }
    20.  
    21.  
    22.     void Update ()
    23.     {
    24.         float _xMov = Input.GetAxisRaw("Horizontal");
    25.         float _xMov = Input.GetAxisRaw("Vertical");
    26.  
    27.         Vector3 _movHorizontal = transform.right * _xMov;
    28.         Vector3 _movVertical = transform.forward * _xMov;
    29.  
    30.         Vector3 _velocity =(_movHorizontal +  _movVertical).normalized * speed;
    31.  
    32.         motor.Move(_velocity);
    33.     }
    34. }
    35.  
    I have that code and that.
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3.     [RequireCompontent(typeof(Rigidbody))]
    4.  
    5.  
    6. public class PlayerMotor : MonoBehaviour
    7. {
    8.  
    9.    private Vector3 velocity = Vector3.zero;
    10.  
    11.    private Rigidbody rb;
    12.  
    13.    void Start ()
    14.    {
    15.         rb.GetComponent<Rigidbody>();
    16.    }
    17.  
    18.    public void Move(Vector3 _velocity)
    19.    {
    20.         velocity = _velocity;
    21.    }
    22.  
    23.    void FixedUpdate ()
    24.    {
    25.         PerformMovement();
    26.    }
    27.  
    28.      
    29.  
    30.         void PerformMovement ()
    31.         {
    32.                 if (velocity != Vector3.zero)
    33.                 {
    34.                     rb.MovePosition(rb.position + velocity + Time.fixedDeltaTime);
    35.                 }
    36.        
    37.         }
    38.  
    39. }
    40.  
    can anyone help me? i have those errors
    Assets\Scripts\PlayerMotor.cs(3,6): error CS0246: The type or namespace name 'RequireCompontentAttribute' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Scripts\PlayerMotor.cs(3,6): error CS0246: The type or namespace name 'RequireCompontent' could not be found (are you missing a using directive or an assembly reference?)
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    "RequireCompontent"

    You made a typo.

    Some tips:

    1. use a proper IDE like visual studio if not already so you can see broken code in the actual text environment and not even need to switch to unity to check

    2. indent better, do it properly and consistently
     
  12. HarryLiuHB

    HarryLiuHB

    Joined:
    Apr 15, 2018
    Posts:
    1
    use Window > Package Manager to install the Multiplayer HLAPI and XR Legacy Input Helpers packages.
     
  13. wondermagic

    wondermagic

    Joined:
    Jul 14, 2017
    Posts:
    5
    It may be a good idea to check your selected target platform. I once had my target platform unknowingly switched from WebGL to PC, Mac, Standalone and it was throwing namespace not found errors
     
    FloraDiep likes this.
  14. HOTBOYZ55241

    HOTBOYZ55241

    Joined:
    Jul 3, 2020
    Posts:
    1
    I'm having a similar problem but not sure how to fix it.





    Code (CSharp):
    1.  
    2. using System.Collections;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5. using System;
    6.  
    7. public class BoxControler : MonoBehaviour
    8. {
    9.     private const float MOVE_SPEED = 60f;
    10.  
    11.     private Character_Base characterBase;
    12.     private Rigidbody2D rigidbody2D;
    13.     private Vector3 moveDir;
    14.  
    15.     private void Awake ()
    16.     {
    17.         characterBase = GetComponent<Character_Base>();
    18.         rigidbody2D = GetComponent<Rigidbody2D>();
    19.     }
    20.  
    21.     private void Update()
    22.     {
    23.         float moveX = 0f;
    24.         float moveY = 0f;
    25.  
    26.         if (Input. GetKey(KeyCode.A))
    27.         {
    28.             moveX = -1f;
    29.         }
    30.  
    31.         if (Input.GetKey(KeyCode.D))
    32.         {
    33.             moveX = +1f;
    34.         }
    35.  
    36.         if (Input.GetKey(KeyCode.S))
    37.         {
    38.             moveX = -1f;
    39.         }
    40.  
    41.         if (Input.GetKey(KeyCode.W))
    42.         {
    43.             moveX = +1f;
    44.         }
    45.  
    46.         moveDir = new Vector3(moveX, moveY).normalized;
    47.         characterBase.PlayMoveAnim(moveDir);
    48.     }
    49.  
    50.     private void FixedUpdate()
    51.     {
    52.         rigidbody2D.velocity = moveDir + MOVE_SPEED;
    53.     }
    54. }
    55.  
    56.  
     
  15. DTheChemist

    DTheChemist

    Joined:
    Jan 18, 2021
    Posts:
    115
    Ok i literally just had this issue and i figured it out matching it up with a similar script from a template.
    add this at the starting top using UnityEngine.Events; i was using public UnityAction onCrouch; within my crouch code and i got the error because i didnt add in the UnityEngine.Events


    example below

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Events;
    5. using Platformer.Gameplay;
     
    nyahchain likes this.
  16. sialihsm

    sialihsm

    Joined:
    Dec 29, 2020
    Posts:
    1
    Try to use namespace on every script you use.
     
  17. DTheChemist

    DTheChemist

    Joined:
    Jan 18, 2021
    Posts:
    115
    @sialihsm. thanks for the reply. the issue been solved months ago.
     
  18. gansolo97

    gansolo97

    Joined:
    May 17, 2021
    Posts:
    2
     
  19. gansolo97

    gansolo97

    Joined:
    May 17, 2021
    Posts:
    2
    I have the same problem
     
  20. Jyesh

    Jyesh

    Joined:
    May 30, 2021
    Posts:
    4
    public void InputComponent(){
    InputField.GetComponent<Text>();
    }

    public void InputNum(){

    TextBox.GetComponent<Text>().text = InputField.InputComponent();
    }



    Can SomeOne Help me whats the problem here?
    Showing same error..

    Assets\Scripts\Count.cs(64,56): error CS1061: 'GameObject' does not contain a definition for 'InputComponent' and no accessible extension method 'InputComponent' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)
     
  21. MuhammadBilalKhan

    MuhammadBilalKhan

    Joined:
    Nov 21, 2021
    Posts:
    1
    Assets\Scripts\MaterialSelector.cs(19,32): error CS0246: The type or namespace name 'Button' could not be found (are you missing a using directive or an assembly reference?)


    i have a problem can someone help out?????
     
  22. deprettheo18

    deprettheo18

    Joined:
    Mar 1, 2021
    Posts:
    1