Advices on C# and Javascript, connecting

Hey there folks, so i have a script that selects and deselects a unit in my game, it’s made in javascript. And then i have an other script that moves the unit to the current mouseposition when clicken, that script is in C#. I want it so the unit has to be selected first before you can move it, and since the scripts are diffrent programming languishes, then i can’t set up some kind of boolean, and then ask the other script if the unit is selected, it have only worked for me with javascripts, now im asking you guys, what do you think im going to do?

~carlqwe

First off - I want to recommend you convert one script to the other language and try and keep your scripts languages consistent because it will just make life easier in the long run.

Anyway - look at this thread and the one linked in it:

http://forum.unity3d.com/threads/communication-between-c-to-javascript.225583/

The answer is in there, you can message a unityscript/javascript from c# with this method. Basically you need to create a variable of the game object with the js script and then to send a message to that object with the name of the function you want to call as a string like “SendMessage(“MyFunction”);”

Good luck!