Cant Add Hacker.cs script

Hi I am getting Error when I try to add a CS script to my hacker unity project.

Step 1) Create Script in Assets
Step 2) set name of script to “Hacker.cs” (no quotes)
Step 3) Drag to WM2000 object - and Receive error
“Can’t add script behaviour AssemblyInfo. The script needs to derive from MonoBehaviour”

Environment
Win10
Unity 2018.3.14f1 / Personal
Visual Studio Community 2017 V15.9.7

Help please; I feel a little stupid with this error.

Kind Regards
Brendan

Hi Brendan,

Your class inside the script is named Hacker.cs, which is not allowed. Rename it to Hacker. Make sure your script is named Hacker and has a file extension named .cs. It must not say: Hacker.cs.cs.

I’ve moved your thread to the “Ask” subforum because you obviously need help with a problem. “Talk” is for, well, talking. :wink:

Thanks.

This worked for me.
Steps I used:

  1. Remove your attempted script from the asset

  2. Right Click and add new script

  3. Name it Hacker and press enter

  4. Drag script to WM2000

  5. On the WM2000 object inspector on right hand side you can see the Hacker script present.

Thanks for your help.

PS: Asking about a problem vs talking about a problem. slightly different perspective; as I wanted to talk about the problem.

//Brendan

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms