Skip to content

Commit 2d83d1e

Browse files
committed
feature: Reload hook for non-shared context.
1 parent d630376 commit 2d83d1e

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

crates/bevy_mod_scripting_core/src/commands.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl<P: IntoScriptPluginParams> Command for CreateOrUpdateScript<P> {
212212
vec![err
213213
.with_script(self.id.clone())
214214
.with_context(P::LANGUAGE)
215-
.with_context("saving reload state")]
215+
.with_context("saving reload state (shared-context)")]
216216
.into_iter(),
217217
);
218218
}
@@ -222,6 +222,27 @@ impl<P: IntoScriptPluginParams> Command for CreateOrUpdateScript<P> {
222222
self.reload_context(guard.clone(), handler_ctxt)
223223
}
224224
None => {
225+
match handler_ctxt.call_dynamic_label(
226+
&OnScriptReloaded::into_callback_label(),
227+
&self.id,
228+
Entity::from_raw(0),
229+
vec![ScriptValue::Bool(true)],
230+
guard.clone(),
231+
) {
232+
Ok(state) => {
233+
reload_state = Some(state);
234+
}
235+
Err(err) => {
236+
handle_script_errors(
237+
guard.clone(),
238+
vec![err
239+
.with_script(self.id.clone())
240+
.with_context(P::LANGUAGE)
241+
.with_context("saving reload state")]
242+
.into_iter(),
243+
);
244+
}
245+
}
225246
bevy::log::debug!("{}: loading script with id: {}", P::LANGUAGE, self.id);
226247
self.load_context(guard.clone(), handler_ctxt)
227248
}

0 commit comments

Comments
 (0)