Search Unity

Script Class Cannot Be Found

Discussion in 'Scripting' started by jerryperkins, Sep 1, 2017.

  1. jerryperkins

    jerryperkins

    Joined:
    Sep 1, 2017
    Posts:
    1
    Hello, I’m as new as they get as far as developing with Unity, and I am currently trying to make a scrolling shooter with the tutorial from this youtube series of videos. (
    )



    I am using a Mac, and when I create a new script and try to add it to the character it says


    “Can’t add script



    Can't add script component 'PlayerControl' because the script class cannot be found. Make sure that there are no compile errors and that the file name and class name match.”



    What am I doing wrong here? I'm sure this is the most basic of all basic problems. Any and all help would be appreciated. :)
     
    ayariayoub and Kouihiere59 like this.
  2. Deleted User

    Deleted User

    Guest

    Did you make sure that the script file name is PlayerControl.cs and the class looks like this:
    Code (csharp):
    1.  
    2. public class PlayerControl : MonoBehaviour
    3. {
    4. //etc...
    5. }
    6.  
     
  3. Icaru

    Icaru

    Joined:
    Apr 12, 2020
    Posts:
    3
    Rename the script file to PlayerControl

    whenever you make a new script you should never put any spaces in the name otherwise it gets combined and wont match with the file's name.
     
  4. Hamstar2

    Hamstar2

    Joined:
    Nov 27, 2021
    Posts:
    2
    Thanks! That was the problem apparently.
     
  5. GoSaiyan_Goku

    GoSaiyan_Goku

    Joined:
    Jun 28, 2022
    Posts:
    2
    Yes that's what you must do!
     
  6. GoSaiyan_Goku

    GoSaiyan_Goku

    Joined:
    Jun 28, 2022
    Posts:
    2
    You helped me learn that a now my whole Garrys mod version works!
     
  7. dartrix910

    dartrix910

    Joined:
    Dec 13, 2022
    Posts:
    3
    that doesn't work for me can you repeat please
     
  8. dartrix910

    dartrix910

    Joined:
    Dec 13, 2022
    Posts:
    3
    Helo????