You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-9Lines changed: 31 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
+
1
2
# UnrealEnginePython
2
3
Embed Python in Unreal Engine 4
3
4
4
5
## Fork Notes
5
6
6
7
This fork is meant to encapsulate python + pip + scripts fully in the plugin and to allow dependency plugins to be built on top of the python plugin. Specifically it means adding automatic pip dependency resolution and automatic sys.path additions such that the resulting two plugins can be fully drag and dropped into a new project.
This is a plugin embedding a whole Python VM (versions 3.x [the default and suggested one] and 2.7) In Unreal Engine 4 (both the editor and runtime).
@@ -25,7 +29,7 @@ Once the plugin is installed and enabled, you get access to the 'PythonConsole'
25
29
26
30
All of the exposed engine features are under the 'unreal_engine' virtual module (it is completely coded in c into the plugin, so do not expect to run 'import unreal_engine' from a standard python shell)
27
31
28
-
The currently supported Unreal Engine versions are 4.12, 4.13, 4.14, 4.15, 4.16, 4.17and 4.18.
32
+
The currently supported Unreal Engine versions are 4.12, 4.13, 4.14, 4.15, 4.16, 4.17, 4.18 and 4.19
29
33
30
34
We support official python.org releases as well as IntelPython and Anaconda distributions.
31
35
@@ -488,6 +492,30 @@ To access the fields of a struct just call the fields() method.
488
492
489
493
A good example of struct usage is available here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/Settings.md
490
494
495
+
As structs are passed by value, you need to pay attention when manipulating structs fields that are structs by themselves:
496
+
497
+
```python
498
+
from unreal_engine.structs import TerrificStruct, DumbStruct
499
+
500
+
ts = TerrificStruct()
501
+
ts.dumb = DumbStruct(Foo=17, Bar=22)
502
+
503
+
# will not modify the original DumbStruct but a copy of it !!!
504
+
ts.dumb.Foo =22
505
+
```
506
+
507
+
You can eventually force structs to be passed by ref (extremely dangerous as the internal C pointer could be a dangling one) using the ref() function:
508
+
509
+
```python
510
+
from unreal_engine.structs import TerrificStruct, DumbStruct
511
+
512
+
ts = TerrificStruct()
513
+
ts.dumb = DumbStruct(Foo=17, Bar=22)
514
+
515
+
# ref() will return a pointer to a struct
516
+
ts.ref().dumb.foo().Foo =22
517
+
```
518
+
491
519
The ue_site.py file
492
520
-------------------
493
521
@@ -809,15 +837,9 @@ Memory management
809
837
810
838
Dealing with 2 different GC's is really challenging.
811
839
812
-
PyActor, PyPawn and PythonComponent automatically DECREF's the mapped classes. This should be enough unless you hold references
813
-
in the python modules themselves. As this would be a bad programming practice, the current approach should be safe enough.
814
-
815
-
In addition to this, every time a uobject has to return its UObject mapping, it checks for its validity and safety:
840
+
Starting from release 20180226 a new memory management system has been added (FUnrealEnginePythonHouseKeeper, available here https://github.com/20tab/UnrealEnginePython/blob/master/Source/UnrealEnginePython/Public/PythonHouseKeeper.h). This new system is completely integrated with the Unreal Engine reflection-based GC and will hold track of each ue_PyUObject abd the related UObject to understand when a python object can be safely destroyed.
816
841
817
-
```c
818
-
#defineue_py_check(py_u) if (!py_u->ue_object || !py_u->ue_object->IsValidLowLevel() || py_u->ue_object->IsPendingKillOrUnreachable())\
819
-
return PyErr_Format(PyExc_Exception, "PyUObject is in invalid state")
820
-
```
842
+
The same system works for delegates, as well as Slate.
0 commit comments