Hi Folks,

I’m not sure how to type a variable in C# using the JavaScript (JS) script name in order to access a variable in the JS script from the C# script. (I hope that’s an accurate description - let me know if I’m not using the terms correctly and I’ll edit)

The JS script is named NumberLauncher.js and has a variable that I’m successfully accessing from other JS scripts with the following:

//[Outside any function]
var nl		: NumberLauncher;
var FireLock 	: boolean;


//[Inside the Start function to create a reference to NumberLauncher]
nl = GameObject.FindGameObjectWithTag("Launcher").GetComponent(NumberLauncher);


//[Inside the Update function
FireLock = nl.Fire_Lock;

Now for my current (unsuccessful) attempt in C#

//[Inside the Class but outside of any functions]
public bool FireLock;
public NumberLauncher 	nl;

//[Inside the Start function]
nl = GameObject.FindGameObjectWithTag("Launcher").GetComponent<NumberLauncher>;

//[Inside the Update function]
FireLock = nl.Fire_Lock;

The error that is reported is:
“The type or namespace name ‘NumberLauncher’ could not be found. Are you missing a using directive or an assembly reference”

I looked through the docs and there was an example of this where both scripts were apart of the same GameObject but I’m missing something, like the error says missing a “using”, but I don’t know how this is used in unity with JS scripts.

I appreciate your help.

Thank you.

Due to the order that things get compiled, you run into this. I’ve taken to just doing everything in C# to save me the trouble. But you can try this: move the js script to a folder called StandardAssets, or Plugins, as those get compiled first.