Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

shiena/Unity-PythonNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

46 Commits

Repository files navigation

Unity-PythonNet

Development Environment

What is this?

This is a sample project that integrates Unity and Python.NET. Pressing the Plot button will display an image of a graph drawn using matplotlib in Python.

Project Structure

+ Assets/
 + Scenes/
 + SampleScene.unity : Main scene using Unity UI
 + MainView.unity : Main scene uning UI Toolkit
 + Scripts/
 + PythonLifeCycle.cs : Python.NET initializer
 + PlotRandom.cs : Call python script from C# using Python.NET for Unity UI
 + UIEventHandler.cs : Call python script from C# using Python.NET for UI Toolkit
 + Plugins/
 + Microsoft.CSharp.dll : Need for .NET Standard 2.1
 + StreamingAssets/
 + python-3.11.3-embed-amd64/ : python runtime
 + myproject/
 + plot_random.py : python script for graph plot
 + requirements.txt : a list of items to be installed using pip install

How to add python packages

cd Assets\StreamingAssets\python-3.11.3-embed-amd64\
.\Scripts\pip.exe install matplotlib
.\Scripts\pip.exe freeze > myproject\requirements.txt

Known Issues

  • PythonEngine.PythonPath is not applied when changing a different PythonEngine.PythonPath after calling PythonEngine.Initialize() / PythonEngine.Shutdown().
    • Restart Unity if you want to set a different PythonEngine.PythonPath.

AltStyle によって変換されたページ (->オリジナル) /