-1
\$\begingroup\$

I was writing the character controller for my player character, but Unity said that there was no mono behavior script in the file I'd written the file right and I included the mono behavior public class ScriptName : MonoBehaviour in the code, is there something missing, or did I write it wrong?

\$\endgroup\$
4
  • \$\begingroup\$ is the file itself named as such as well? \$\endgroup\$ Commented Apr 18, 2023 at 16:33
  • 1
    \$\begingroup\$ Please double check your usage of the UnityScript tag. As mentioned in the UnityScript tag info, it's for a legacy option that was removed in version 2017.2; you probably want the combination of the Unity and C# tags instead. Regarding your error, it doesn't seem like there's not enough info provided. Including a minimal reproducible example would help with that. \$\endgroup\$ Commented Apr 18, 2023 at 19:08
  • 2
    \$\begingroup\$ "is there something missing" to answer that, we need to see more than this one line in isolation. We need the full steps to create a Minimal Complete Verifiable Example. Create a new project. Create a new script file. Write the bare minimum code you need to write to reproduce the problem, noting down every step you took. Edit your question to list all these steps so a reader can replicate exactly what you've done. Be sure to include the full text of any console error messages too. Once we have this detail, we can help you troubleshoot in depth, and test potential fixes to be sure they work \$\endgroup\$ Commented Apr 18, 2023 at 21:45
  • \$\begingroup\$ Common errors to check for here are: whether the name of the class exactly matches the name of the file, and whether that class is the first definition in the file. \$\endgroup\$ Commented Apr 19, 2023 at 14:35

1 Answer 1

0
\$\begingroup\$

Please make sure that you include the proper packages or libraries with the using statements at the top of the file.

For example, this is a simple script that should work:

using UnityEngine;
using UnityEngine.UI;
using System;

public class My_First_Script : MonoBehaviour
{
}

If you can post your whole script to your question, then we can help you better.

\$\endgroup\$
2
  • \$\begingroup\$ It didn't work, unity still says there is no mono behaviour script \$\endgroup\$ Commented Apr 19, 2023 at 1:22
  • 1
    \$\begingroup\$ @INDO_GEMENG, Can you post your script on your original post ? This way, we can look at your code and possibly tell you what is wrong. \$\endgroup\$ Commented Apr 19, 2023 at 3:48

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.