Jump to content

Csharp Export Variables


photo

Recommended Posts

Hi,

 

I need to pass three initialization variables declared and obtained from an external dll in the init function of the Csharp AppWorldLogic.cs to the Uniginescript part to initialize the some control values.

 

After looking the documentation, I found that a declaration is needed in the Project.cs using:

 

Interpreter.addExternVariable()

 

The problem is that if I use this command on the Appworldlogic.cs init function, the variables are not recognized in the UnigineScript part. If the declaration is made in the Project.cs with the help of a public class and {get, set,} to declare the variables, any change made after that in the variables is not reflected in the UnigineScript side.

 

Which is the way to do it? 

 

Thanks!

Link to comment

Hi Manuel,

The trick is to declare the variable before the script that uses it will be actually loaded by the engine.
There is no method in WorldLogic suitable for declaring variables used by the world script.
You can put your addExtern*() calls in the SystemLogic::init() or simply in the Main() function.

Unfortunately, C# API lacks some functionality available in C++ and Interpreter.addExternVariable() doesn't create any connection between C# and Unigine Script.
It just declares a script variable and initializes it with some value.
I can't see any way of exporting C# variable into the script.
For C#-script interop I'm afraid extern functions and extern classes are only left options.

Link to comment
×
×
  • Create New...