Can't add scripts - "Can't add script behaviour TMP_CoroutineTween [...]".

I get this error message in a pop up while trying to add a script to a empty GameObject:

can’t add script behaviour
TMP_CoroutineTween

Have no idea of why. It appears insistently each time I try to drag and drop the script to the game object. Finally I closed and reopen Unity3D Editor, deleted the game object end created a new one and I was able to ad the script, so now the problem for me was solved.

But I wanted to report this because I think this could be useful to somelse that could have the same problem.

It could be a bug of the Editor, I suppose.

Answer Edit:
The issue is caused when changing the script file name after creating it. The class name within the script at the top of the file must also match the file name.

Quote from documentation: The name of the class is taken from the name you supplied when the file was created. The class name and file name must be the same to enable the script component to be attached to a GameObject.

Hope this helps someone as it fixed it for me. =)

Cheerio,
Cormac


Hi,

I too am having this issue in latest Unity 2018.2.3f1 where I right click in project folder and create new C# Script. I change name to CharacterBehaviourScript and it contains the default text.

Now if I try drag this onto my player object, I get the same error. I’ve found no way around this, so I don’t think it’s my script as I was following a YouTube tutorial with the exact same code.

Please advise?

If that “TMP_CoroutineTween” script file is from TextMesh Pro, then you’re not supposed to add it to a gameobject. Only MonoBehaviours can be added as component to a gameobject. Not every script file contains a MonoBehaviour derived class. It seems you’re using third party code here and just don’t understand how to use it. So i recommend to read the documentaion of that third party product.

This is certainly no bug in Unity. As far as i can tell from a version i’ve found on the net, the “TMP_CoroutineTween.cs” file contains only internal classes and structs of the TextMeshPro framework.

I met the same problem when I tried to attach PlayerController.cs to a game project. The VS debug errors analysis indicates PlayerController this name is kinda an exiting class or function. After I changed the cs name it became fine.maybe you can try this way.

I had same problem. Deleting TextMeshPRo completly from project and than adding it again helped me

Same Problem too often
1.Created & Named new script using Visual Studio 2017. Didn’t rename it or anything else.

  1. Tried to attach script to game Object/ Any Object.
  2. Got then and gets now “Can’t add script behaviour tmp CoroutineTween. The script needs to derive from monoBehavior”
  3. I usually get around this problem by creating a new script and a new name, but not this time.

Defeated but not gone!