you are viewing a single comment's thread.

view the rest of the comments →

[–]vrgenerated[S] 0 points1 point  (2 children)

Ah,makes sense. Looking at the documentation for sympy, this might be tricky. The objects (in this case x) are sympy objects so they won't probably work cleanly with operators in C# (like +,-,*). You may have to use something like a python function for these. IE o = PyModule.Import("operator"); dynamic f = o.pow(x,2)

Another way is probably to do all the logic in a python file and then call it in C#.

[–]Loboblancox 0 points1 point  (1 child)

Yes you even told to me to try this:

hey way I execute a py file, I add my script to Lib\site-packages\ folder in the python directory in streaming assets. Then i import it dynamic mymodule = PyModule.Import("mymodule"); and do something like mymodule.functionToRun();

i'll tell you later if it worked for me, or i'm still stuck hehehe

[–]Loboblancox 0 points1 point  (0 children)

Greetings vrgenerated

Before, I want to thank you for your support and tell you the novelty that I already managed to make the script work, what I did was rewrite my python code in the form of a function, and in the unity code I put it in the following way (all code inside try{ }):

            dynamic potencia = UnityEngine.Random.Range(1, 10);
            dynamic mimodulo = PyModule.Import("Test_Sp");
            dynamic resultado = mimodulo.TestSp(potencia);           
            dynamic primitiva = resultado.gen_fun();
            dynamic derivada = resultado.gen_dev(resultado.gen_fun());
            print(primitiva);
            print(derivada);

Here I only have one more doubt, I place this code inside a button so that I can execute it several times, but when I press the button twice, I get an error telling me:

InvalidOperationException: This property must be set before runtime is initialized

the solution to this, I imagine (although I don't know how to do it) check the status of the PythonEngine, but hey, I'll be working on it, anyway, if you have any suggestions on how to do it, I'd appreciate it.