Toggling a Javascript from a C# script

So I’m running a controller C# script that will toggle a number of other scripts based on the state the player is in.

Right now I’m hitting the problem that two of these scripts are JS. For the C# scripts, I can simply call them and enable/disable them in the Update of this controller, but I know you can’t communicate with a JS from a C# script very easily.

How do I get around that?

EDIT:
For some specificity, the two Javascripts are the standard FPS Input Controller and the Character Motor from the First Person Controller prefab. If there’s any alternative to these out there, that would also solve my problem.

I’ve also just read a little bit about using the SendMessage function to pass a value from C# to Javascript, but I don’t know a lot about how to do this. Any insight is appreciated.

I figured it out, actually! SendMessage is really easy to use. Here’s what I ended up doing.

Threw this into my C# controller (the controller is run on the same gameobject as all of the other scripts).

this.gameObject.SendMessage("InOutToggle",true);

Passing in true toggles it on, passing in false toggles it off. Simple.

Then put this in both of my Javascripts.

function InOutToggle (onOff) {
	this.enabled = onOff;
}

Worked like a charm. Hope this helps anyone else trying to communicate between JS and C#.

You can access javascript from c# by placing them in standard assets folder or plugins folder.