How can I use Photon or any other C# library? #31
-
First of all, you made a GREAT solution for Pythonheads like me! Not only because it allows us to use Python, but also because now I can debug things and change the code on the fly without recompiling and restarting the game! I'm just loading a Python script every 5 seconds, and whenever I change it, the changes are getting applied. Magic! Well, back to the question. I looked through the list of issues and I see people asking how to use various Python libraries in their Python scripts. However, I'd like to know if it's possible to use C# libraries, like Photon, from the Python code. I tried to I'd like to play with the networking and do things like |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Yes, you should be able to do that. You can see an example of something similar happening in the However, in order for this to work, you need to load the assemblies when you create the engine. You can see an example of that in // Load assemblies for the `UnityEngine*` namespaces
foreach (var assembly in GetAssembliesInNamespace("UnityEngine"))
{
engine.Runtime.LoadAssembly(assembly);
} If you add the assembly containing |
Beta Was this translation helpful? Give feedback.
-
It's been more than a month with no responses, so I'm closing this issue for now. I'm not sure if you need any more help on this issue, but feel free to re-open this issue if you still need help with using C# types in Python. |
Beta Was this translation helpful? Give feedback.
Yes, you should be able to do that. You can see an example of something similar happening in the
PythonUnityHelloWorld.cs
example.However, in order for this to work, you need to load the assemblies when you create the engine. You can see an example of that in
UnityPython
, which is used in the example. I've included the relevant snippet below:If you add the assembly containing
PhotonNetwork
to the runtime, you should be able to find the type in Python. Let me know if this isn't the case.