C# to js communication

My main script (MultipleScript.cs), which manages all the logic of the game, is written in c#. It handles some objects (let’s say, like the health pickups in the tutorial): each of them has a corresponding integer value, saved in the attached script (StarScript.cs).

StarScript should also manage the rotation of these pickups, involving yield: I still haven’t been able to make yield work properly in c#, so I was thinking about rewriting the script in js; BUT I need to access the aforementioned integer value from the main script (via getter / setter methods), and I do not know how to call a js function (especially the getter: I don’t think the proper way to implement it is to have cs send a message to the receiver js method and then having this method send another message back - what’s more, I can neither make this solution work) from a c# script.

I’d be really, really grateful if anybody could help me.

EDIT: During the morning I managed to learn how to properly use coroutines :smile: Still, I’m curious about how I can make my mixed scripts communicate (the getter question is still open).

Hi

Making JS and C# scripts communicate does AFAIK only work in one way.
Place the JS script in your plugin folder, then the C# can access the JS script (call functions and get a return).

You can read the section on compiling order in the docs.

What I can’t really catch is how I can get a return…

You can not talk into both directions.

Either JS can access C# or C# can access JS

If you require a talk into both directions, use the same language, not two distinct ones.