FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Unity-PythonNet/Assets/Scripts/PythonLifeCycle.cs at wait-finish-python · nwy140/Unity-PythonNet · GitHub
nwy140
/
Unity-PythonNet
Public
forked from
shiena/Unity-PythonNet
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Unity-PythonNet
/
Assets
/
Scripts
/
PythonLifeCycle.cs
Copy path
More file actions
More file actions
Latest commit
History
History
History
65 lines (56 loc) · 2.31 KB
Breadcrumbs
Unity-PythonNet
/
Assets
/
Scripts
/
PythonLifeCycle.cs
Copy path
File metadata and controls
65 lines (56 loc) · 2.31 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using
Python
.
Runtime
;
using
System
;
using
UnityEngine
;
namespace
UnityPython
{
public
static
class
PythonLifeCycle
{
private
const
string
PythonFolder
=
"python-3.11.3-embed-amd64"
;
private
const
string
PythonDll
=
"python311.dll"
;
private
const
string
PythonZip
=
"python311.zip"
;
private
const
string
MyProject
=
"myproject"
;
private
const
string
TestProject
=
"test_project"
;
[
RuntimeInitializeOnLoadMethod
(
RuntimeInitializeLoadType
.
BeforeSceneLoad
)
]
private
static
void
PythonInitialize
(
)
{
Application
.
quitting
+=
PythonShutdown
;
Initialize
(
)
;
}
private
static
void
PythonShutdown
(
)
{
Application
.
quitting
-=
PythonShutdown
;
Shutdown
(
)
;
}
public
static
void
Initialize
(
)
{
var
pythonHome
=
$
"
{
Application
.
streamingAssetsPath
}
/
{
PythonFolder
}
"
;
var
myProject
=
$
"
{
Application
.
streamingAssetsPath
}
/
{
MyProject
}
"
;
var
testProject
=
$
"
{
Application
.
streamingAssetsPath
}
/
{
TestProject
}
"
;
var
pythonPath
=
string
.
Join
(
";"
,
$
"
{
myProject
}
"
,
#if
UNITY_EDITOR
$
"
{
testProject
}
"
,
#endif
$
"{pythonHome}/Lib/site-packages"
,
$
"
{
pythonHome
}
/
{
PythonZip
}
"
,
$
"
{
pythonHome
}
"
)
;
var
scripts
=
$
"
{
pythonHome
}
/Scripts"
;
var
path
=
Environment
.
GetEnvironmentVariable
(
"PATH"
)
?
.
TrimEnd
(
';'
)
;
path
=
string
.
IsNullOrEmpty
(
path
)
?
$
"
{
pythonHome
}
;
{
scripts
}
"
:
$
"
{
pythonHome
}
;
{
scripts
}
;
{
path
}
"
;
Environment
.
SetEnvironmentVariable
(
"PATH"
,
path
,
EnvironmentVariableTarget
.
Process
)
;
Environment
.
SetEnvironmentVariable
(
"DYLD_LIBRARY_PATH"
,
$
"
{
pythonHome
}
/Lib"
,
EnvironmentVariableTarget
.
Process
)
;
Environment
.
SetEnvironmentVariable
(
"PYTHONNET_PYDLL"
,
$
"
{
pythonHome
}
/
{
PythonDll
}
"
,
EnvironmentVariableTarget
.
Process
)
;
#if
UNITY_EDITOR
Environment
.
SetEnvironmentVariable
(
"PYTHONDONTWRITEBYTECODE"
,
"1"
,
EnvironmentVariableTarget
.
Process
)
;
#endif
PythonEngine
.
PythonHome
=
pythonHome
;
PythonEngine
.
PythonPath
=
pythonPath
;
PythonEngine
.
Initialize
(
)
;
}
public
static
void
Shutdown
(
)
{
PythonEngine
.
Shutdown
(
)
;
}
}
}
Back
|
FazBrowse Home
|
New Git URL