Unity3d: Change value of the variable in C# script from UnityScript JS

Hi,

The entire game was programmed in Unity3d with UnityScript(JS), however one C# script was included (GameCenter integration).

At the moment Game Center Script (C#) is attached to the First Scene Object (not destroyable object, not sure if it needs to be not destroyable, please advise).

In another scene, where GameOver is happening, when GameOver is triggered, the attached UnityScript(JS) has to be able to change Variable in the C# script (from false to true).

(Once the Variable in C# changes to true, score is being submitted to Game Center with the help of C# script.)

Changing variables from one UnityScript in another is not a problem, but how to change variable in C# from the UnityScript?

In Unityscript it would be something like that:
GameCenterJS.gameOver = true;

But it doesn't work as
GameCenterCS.gameOver = true;

What is the proper way to do it?

Thank you for your advice
user4578Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

 
Hans LangerCommented:
So, you have an object with a c# script that is accessible from another object that have a JS script.
The option that i would trye would be:

1) create a "gameOver" Public Function in the c# script, so you just can call it from the JS using: GameObject.gameOver(false), and inside the function i would change the value of the variable.

2) or you can have a static class that contain all the "shared" variables.
0

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.