How to access a static variable in c# from js

Hey !
Can anyone please help me in accessing a static int variable declared in c# from Javascript.
I have keep in minded the compilation order but Still no luck .
Your help would be appreciated

Hey bud,
If your code to access it is sound, you must then place the Java/UnityScript file into a folder named “Plugins” or anywhere below that folder (i.e. a folder structure like… “Plugins->JS”)
This is due to what is known as script execution order.
Both these language are not compiled together or even in the same way, making them incompatible until they are both at an intermediate stage etc.
If you place your JS file in a Folder as mentioned above, you will ensure it is compile prior to any C# script accessing during compilation/setups etc.
This link will be invaluable to you by the sounds of things to come, read it and bookmark it…


Take care bud.

State the scriptname before the variable like this.
After writing this i realized that you actually cant access Javascript from C#
But Javascript can atleast access C#.

//1st script (script1)

var MyVar = 1;

function Start(){

     Myvar = script2.OnorOff;


//2nd script (script2)

var OnorOff = 2;

//Now MyVar is equal to you other OnorOff variable in another script.

//Sadly, im not good in c# so this might not be what you need. 
//But this is what i use to access other varibles in other scritps.