Skip to content

Commit b6058c9

Browse files
author
Roberto De Ioris
authored
Update README.md
1 parent 979d832 commit b6058c9

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,30 @@ To access the fields of a struct just call the fields() method.
487487

488488
A good example of struct usage is available here: https://github.com/20tab/UnrealEnginePython/blob/master/docs/Settings.md
489489

490+
As structs are passed by value, you need to pay attention when manipulating structs fields that are structs by themselves:
491+
492+
```python
493+
from unreal_engine.structs import TerrificStruct, DumbStruct
494+
495+
ts = TerrificStruct()
496+
ts.dumb = DumbStruct(Foo=17, Bar=22)
497+
498+
# will not modify the original DumbStruct but a copy of it !!!
499+
ts.dumb.Foo = 22
500+
```
501+
502+
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:
503+
504+
```python
505+
from unreal_engine.structs import TerrificStruct, DumbStruct
506+
507+
ts = TerrificStruct()
508+
ts.dumb = DumbStruct(Foo=17, Bar=22)
509+
510+
# ref() will return a pointer to a struct
511+
ts.ref().dumb.foo().Foo = 22
512+
```
513+
490514
The ue_site.py file
491515
-------------------
492516

0 commit comments

Comments
 (0)