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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

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:
    265
    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

    Unity Technologies

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