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: tutorials/AsyncIOAndUnrealEngine.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -93,6 +93,32 @@ Want to integrate an HTTP server into UE ? doable. Want to wait for a redis pubs
93
93
94
94
## Adding an asyncio loop engine in the UE4 core
95
95
96
+
We will start by adding a new (pretty simple) module to our project (call it ue_asyncio.py):
97
+
98
+
```python
99
+
import asyncio
100
+
import unreal_engine as ue
101
+
102
+
loop = asyncio.new_event_loop()
103
+
104
+
defticker_loop(delta_time):
105
+
try:
106
+
loop.stop()
107
+
loop.run_forever()
108
+
exceptExceptionas e:
109
+
ue.log_error(e)
110
+
returnTrue
111
+
112
+
113
+
ticker = ue.add_ticker(ticker_loop)
114
+
```
115
+
116
+
Do not run this module, it will be just the 'hub' the other parts of our project will connect too.
117
+
118
+
Basically when you first import this module a new 'ticker' will be registered into Unreal Engine. A ticker is a function that periodically 'ticks'. In this case Unreal Engine will use this ticker function to wake up the asyncio loop engine to manage all of the coroutines registered to it.
0 commit comments