My project was originally written in JS, but some newer parts have to be written in C#. How can the new scripts access vars from the JS scripts?
This is in the JS SceneController script (which is attached to a game object called SceneController):
var foo : GameObject[ ];
and what I’d like to do in the C# script is access foo, but the compiler just tells me that SceneController is unknown.
I looked through various answers in this forum but nothing worked out. I did try moving the C# script to a different place than the JS script to change the compile order; didn’t help.
Am I going to have to rewrite the older code in C#?
Make a “Standard Assets” folder within your “Assets” folder and put “SceneController.js” in it.
Compile and run it. I hope it ll help.
Hello.
Fist of all use the add new comment to reply and not Your answer, because it will get messy.
Second, I don’t know if you make some search, because it take me 10 second to find an answer.
I highly recommend you to convert all your scripts to the same language, because when you’re working on a big games it is become tough to control. I search “convert unity js to c#”, in Google, and the first link that pop-up was : Convert unity javascript (unityscript) to C#.
If you still want to acces from JS to C# then I search “Unity 3d js to c#” and the fifth link that pop-up was : Unity3D: JavaScript → C# or C# → JavaScript access | 41 Post.
Hope I’ll help you with your problem and also how to post a good question. Don’t take it to personal, just make attention.
Best Regards,
NbO
You Can use Send Message Function to access for set Values for variables .