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: docs/src/ScriptPipeline/pipeline.md
+69-1Lines changed: 69 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,72 @@ In versions prior to `16.0` the pipeline was represented by load unload commands
9
9
10
10
The new pipeline works like this:
11
11
- A set of systems in `PostUpdate` "filter" incoming `ScriptAttachedEvent` and `ScriptDetachedEvent`'s as well as `ScriptAssetModifiedEvent`'s (some generated from asset events, others from component hooks). The filtered events are wrapped in `ForPlugin<P>(inner)` events based on the language of the underlying event's.
12
-
- Then inside the `ScriptProcessingSchedule<P>`
12
+
- A set of other systems then converts those into active `ScriptMachine`'s
13
+
- Then inside the `ScriptProcessingSchedule<P>`, which is only run if there are active machines, we tick each machine until it either errors or reaches its final state.
14
+
15
+
## Script Machines
16
+
17
+
### State Machine
18
+
Script loading is handled by the following state machines:
Hooks, such as `on_script_loaded` are implemented using `TransitionListener`'s which can be inserted into the `ActiveMachines` resource. This allows you to hook into various parts of the loading process and add your own callbacks, i.e.:
The machine ticking by default is limited to 16ms per run (i.e. 60fps assuming it has the entirety of the frame to run). This is not entirely effective as some operations are not currently very fine grained, for example if a callback takes more than 16ms it will easilly hog the frame time.
71
+
72
+
This is however effective when a lot of scripts are loaded in at once, as loading will be spread out over multiple frames.
73
+
74
+
You can override this and many other settings (including disabling the core callbacks) by changing the `ScriptLoadingPipeline<P>` settings via your scripting plugin's `set_pipeline_settings`.
75
+
76
+
The script loading/unloading order will look as follows:
77
+
- the order in which components are attached/detached, will determing what order scripts will be processed
78
+
- scripts are processed one-by-one, i.e. each machine is ticked to completion before the next one is started
79
+
- meaning for example if two scripts are loaded, their `on_script_loaded` hooks will not run at the same "lockstep".
80
+
- loading/unloading might happen over multiple frames, depending on the pipeline's settings.
0 commit comments