How do you open a Unity/C# project using python code (pycharm)?
I have a unity app and I am writing a script to open the app in the background and sign it. I’ve completed this task for Windows but the same code doesn’t work for Mac, as expected.
Even if I change the paths, I keep facing 2 errors, (1) file/folder not found & (2) not enough permission.
So how could I open a project in Unity or a C# solution in my python code for MacOs?
I can open Unity using:
UNITY = ["/usr/bin/open", "-W", "-n", "-a", "Unity.app"]
subprocess.run(f'{UNITY} -projectPath /Users/graphic/Documents/GitHub/proj')
On windows, all runs well using:
subprocess.run(
f'{UNITY} -quit -projectPath C:\Project\Location -batchmode -executeMethod BuildScript.BuildAll')
1
On MacOS, the actual executable file is inside the Unity.app directory (an .app file is really a folder).
The right path may be something like /Applications/Unity/Hub/Editor/2021.1.28f1/Unity.app/Contents/MacOS/Unity
, depending on which version you installed and where you let the Hub install it, or where you installed it yourself.
I don’t know how it works in combination with Python but I suspect you should set your {UNITY}
variable to a path like my example path.
1