Cross Script Communication JS<-->CS

I’m having a hard time getting a JS script and a CS script talking to eachother. It might not even be possible.

Basically i have an array in a JS file i want to give to a CS script, but no matter what i do it errors. This is some example code demonstrating a lack of communication between the script types. I have no problems with JS->JS.

Javascript file:

function Update () {
	NewBehaviourScript.quest=false;
}

C# file:

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {

	
	
	static bool quest = false;
	// Use this for initialization
	void Start () {
	quest = true;
	
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}

In this instance, i get the error:

Assets/first.js(3,1): BCE0005: Unknown identifier: ‘NewBehaviourScript’.

If i try accessing the JS file from the C# file it gives the error:
Assets/NewBehaviourScript.cs(17,9): error CS0103: The name `first’ does not exist in the current context

–Eric

Oh, i see it has something to do with the order of compiling. This is a little odd. I’ll try creating a folder called Standard Assets and put a script in it and see how it goes.

Unfortunately this still doesn’t work.

I placed the C# file in a folder called Standard Assests and when i try to access the bool quest, it says

Assets/first.js(3,38): BCE0120: 'NewBehaviourScript.quest' is inaccessible due to its protection level.

If i try to call a function from the C# file it says:

Assets/first.js(4,28): BCE0020: An instance of type 'NewBehaviourScript' is required to access non static member 'Update'.

It has to be a public static bool rather than static bool. Although frankly you’re better off sticking to one language in most cases.

–Eric

I agree about sticking to one script type. I’m just trying to make use of a script i converted from C++ to C#. With all the hassle, i might try converted it to js instead of c#.

the public static works. Thanks for the help!

is there a solution for Ramens 2nd Error in the 1st Post???

from cs
(Assets/NewBehaviourScript.cs(17,9): error CS0103: The name `first’ does not exist in the current context )

i tried the public static and didnt work

Assets/Scripts/Login/User.cs(1514,39): error CS0176: Static member `User.Stats.eq1’ cannot be accessed with an instance reference, qualify it with a type name instead

public int

error CS0122: `User.stats’ is inaccessible due to its protection level