Skip to content

Commit c6dd4c8

Browse files
author
Roberto De Ioris
authored
Update MemoryManagement.md
1 parent 3b7758c commit c6dd4c8

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

docs/MemoryManagement.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Pay attention, as once you tell the UE GC to not destroy a UObject, that UObject
5252

5353
## Strategy 1: Setting UObject flags to govern the GC
5454

55-
When you create a UObject (from the C++ side, via the NewObject<T> api call) you can specify a bitmask of flags. By default the python api only use the RF_Public flag:
55+
When you create a UObject (from the C++ side, via the ```NewObject<T>``` api call) you can specify a bitmask of flags. By default the python api only use the RF_Public flag:
5656

5757
https://api.unrealengine.com/INT/API/Runtime/CoreUObject/UObject/EObjectFlags/index.html
5858

@@ -79,6 +79,8 @@ Eventually you can reset/set the flags:
7979
```python
8080
import unreal_engine as ue
8181

82+
from unreal_engine.classes import BlueprintFactory
83+
8284
factory = BlueprintFactory()
8385
factory.set_obj_flags(ue.RF_PUBLIC|ue.RF_STANDALONE)
8486

@@ -107,6 +109,8 @@ The root set is a very specific part of the GC tree. If you want to hold control
107109
```python
108110
import unreal_engine as ue
109111

112+
from unreal_engine.classes import BlueprintFactory
113+
110114
factory = BlueprintFactory()
111115
factory.add_to_root()
112116

@@ -151,3 +155,34 @@ factory = tracker.track(BlueprintFactory())
151155

152156
As an example when running a script multiple times, the 'tracker' id will be overwritten, triggering the destruction of the mapped python object (and its ```__del__``` method)
153157

158+
## Low-level UObject creation api
159+
160+
Til now you have seen how to create new UObject's in a very pythonic way:
161+
162+
```python
163+
from unreal_engine.classes import BlueprintFactory, Material, MaterialFactoryNew
164+
165+
bp_factory = BlueprintFactory()
166+
material = Material()
167+
# the first argument here (None) is the outer UObject
168+
material_with_a_name = Material(None, 'FooBar001')
169+
mat_factory = MaterialFactoryNew()
170+
```
171+
172+
While the automagic python UObject creation api is really handy, sometime you want lower-level access to the ```NewObject<T>``` C++ api:
173+
174+
```python
175+
import unreal_engine as ue
176+
from unreal_engine.classes import Material
177+
178+
material = ue.new_object(Material, None, 'DumbMaterial001', ue.RF_PUBLIC|ue.RF_STANDALONE)
179+
``
180+
181+
or for more dynamic class specification:
182+
183+
```python
184+
import unreal_engine as ue
185+
186+
# you can reference to Unreal classes with a string
187+
material = ue.new_object(ue.find_class('Material'), None, 'DumbMaterial001', ue.RF_PUBLIC|ue.RF_STANDALONE)
188+
```

0 commit comments

Comments
 (0)