Are you attempting to attach this as a component? Because you canāt do that. (I ask because you have the method Update, and a mention of OnMouseDown, which are messages that can only be received by components).
No where, I just get the warning āThe class named āLockCursorā is abstract. The script class canāt be abstract!ā
No its not going to be attached to a componant, however the functions āfreeMouseā & ācaptureMouseā will be executed from a componant on a gameobject (I doubt this is the issue as it works fine on a simmiler script and the triggers havnt been writen yet)
Ah sorry, ignore that, I switched the 2 words around incase if it was talking about another script i had and they were colliding or something, no types, the filename & method/script name is āCursorLockā.
I will quickly update the post, sorry for the confusion
I had a bad feeling this would happen, found a post eariler in the day simmiler to this and the guys did the same thing you did. So maybe a bug (most likely) although i do have the latest version (4.6.1f1).
Any ideas of what I should do? In the meantime iāll delete the script and recreate it, see if that gives it a kickā¦
Oh dear, now ive made it worse, the errors gone away and ive now turned it into an instance etc to double check and its now working and im now greeted with the āThe referenced script on this Behaviour is missing!ā Rawr!!!
For those finding this thread in the future, why not close it out by describing how you fixed it. Thereās nothing more aggravating than searching forever for a solution to an obscure problem, finally finding someone who had the same problem, and the thread ending with ānever mind - I fixed itā¦ā
The Fix ladies and gents!
āThe class named āLockCursorā is abstract. The script class canāt be abstract!ā Fix.
Note: This MIGHT work for all languages (C#, JS & Boo).
Warning: Before you attempt the fix, make a note of where you script is being used. (Right click on the script and select āFind References in Sceneā and the Hierarchy will state where the script is being used) and then remove the script from ALL gameobjects & prefabs. This will help to avoid the āThe referenced script on this Behaviour is missing!ā warning.
Copy ALL (āusingā and āclassā included) the code and paste it to notepad or something.
Delete the script from the Project window
Recreate the script with the EXACT same name
Open it up in MonoDevelop (or what ever program your using)
Paste back in the original code (All of it, āusingā and āclassā included)
Now it hopefully should be fixed
Im guessing the reason this happened is maybe the file is corrupted or something went wrong with the file during creation or saving.
This did not work for me unfortunately. My base class inherits from Monobehaviour and is abstract. My class inherits from my abstract base class, but it itself is not abstract. I implement all abstract methods from the base class, but still get the Canāt add script - Canāt add script behaviour. The script canāt be abstract! The error is incorrect, I have plenty of other classes implemented the exact same way, but for some reason this one wonāt work.
Set your derived class to inherit from Monobehaviour instead of your absract base class.
Add a component of your class to your GameObject.
Uncomment the body of your derived class, and inherit from your abstract base class.
Not ideal, but at least I am working again. This is a terrible bug. I have to follow this procedure any time I want to add my derived class to a game object.
In case anybody finds this thread I just had the same problem. It occurred after refactoring some code. Everything looked OK, scripts were saving, but I couldnāt add scripts to objects without a warning. The solution was to check the compiler for errors and sure enough, 2 big red compiler errors sitting in the Unity Console. Sorted those out and re-saved the scripts⦠compiler errors gone and I could set the app to run⦠after that, no problem carrying on adding scripts to objects.
Basically, if there are compiler errors in Unity it will not compile the scripts you have written even if you have changed them in an editor to be correct.