How to use Farseer Physics (C# Package) in Javascript?

I’ve downloaded Farseer Physics for Unity and imported it into a new project. Farseer is a C# / Unity port of a 2D physics engine based on Box2D.

There are many new classes such as Fixture and Body, but I cannot declare them in Javascript like:

var fixture :Fixture; // does not work.

Please help.

I’m unable to download this package at the moment, but I was able to look at the oldest GitHub version, and classes there are in namespaces. If classes in Asset Store version are in namespaces as well, and I think they are, then you have to import namespace first. For example, both Fixture and Body are in namespace FarseerPhysics.Dynamics, so you need

import FarseerPhysics.Dynamics;

on top of your script.

In addition, if this package is not imported into Standard Assets folder (or any other folder which is compiled before your main scripts), then you can’t access C# classes from JavaScript by default. To fix it, package content has to be moved to Standard Assets or Plugins folder.

EDIT: converted to answer.