Do all C# scripts have to inherit from MonoBehaviour?

I ask because the extra math functions in the community wiki don’t seem to e.g.

http://www.unifycommunity.com/wiki/index.php?title=Mathfx

using UnityEngine;
using System;

public class Mathfx
{
public static float Hermite(float start, float end, float value)

How would you reference these in code? GetComponent wouldn’t work as it isn’t attached to a game object.

You either create instances of these classes yourself, or reference static functions with a class name. In Mathfx case, all funcitons are static, so you just write like:

something = Mathfx.Hermite( something );

In short, if a class does not inherit from MonoBehaviour, then it’s not a Unity component and can’t be added to game objects via GUI. But all the regular programming rules still apply - you can create instances of this class from code, reference static functions, etc.

Will this method work when calling C# from javascript code?
e.g.

public class MyCSharpClass
{
   public static DoSomething()
   {
      ...
   }
}

Javascript:

function Update() {
   MyCSharpClass.DoSomething();
}

Yes, but you have to watch out for compilation order. For this to work, the C# script must be compiled first (otherwise JavaScript won’t find it).

The order of scripts compilation is described here. At the end it mentions the C#-with-JS case.