Can't add script behaviour ScriptName. The script class can't be abstract!

Hey guys,
Getting this strange warning at runtime.

“Can’t add script behaviour ScriptName. The script class can’t be abstract!”

I’m using AddComponent through javascript to add a component that’s a separate C# file. Does anyone know what this means? Thanks!

-juanelo

Check the file for “ScriptName.” If the top of the file (after any lines that start with “import [...]”) reads public abstract class ScriptName, then the class is an abstract class. These types of classes are used as a sort of template for other classes that have similar functionality. If you got ScriptName from some external library and ScriptName itself is abstract, chances are the original author wanted you to use one of the more specific types. If you don’t need anything beyond the base functionality of the abstract class, you would create your own C# script on along the lines of

public class MyScriptName : ScriptName
{
}

If the compiler complains that MyScriptName hasn’t implemented some abstract member, just create those functions, ie

public class MyScriptName : ScriptName
{
    public override void AbstractFunction ()
    {
    }
}

However, if the function needs to return something, you’ll have to decide how to handle that. In any case, the base class (in this case ScriptName), must derive from MonoBehaviour at some point, or you’ll never be able to add it as a component.