Search Unity

Question How to fix error cs0246

Discussion in 'Getting Started' started by BubbaHuds, Jul 3, 2022.

  1. BubbaHuds

    BubbaHuds

    Joined:
    Jul 3, 2022
    Posts:
    4
    do not really understand what I am suppose to do.

    below is my programming.
     

    Attached Files:

  2. BubbaHuds

    BubbaHuds

    Joined:
    Jul 3, 2022
    Posts:
    4
    Assets\playerScripts.cs(31,30): error CS0246: The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)
     
  3. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    322
    In the playerScript.cs the approperiate using is probably missing at the start of the file:
    Code (CSharp):
    1. using UnityEngine;
    In C# all classes, interfaces, enums, etc. are part of the namespaces. You have to tell the compilter to use these namespaces defined with "using".
    Other option is to specify the namespace right before the class like
    Code (CSharp):
    1. UnityEngine.MonoBehavior
    See also https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/namespaces
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Is this a homework assignment? This isn't Unity code, there are 3 classes in one file.