Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Migrating from 0.22 to 0.23

Scripts

Script components need a namespace

register_new_component takes a script.* namespace first:

- local Enemy = world.register_new_component("Enemy")
+ local Enemy = world.register_new_component("script.my_game", "Enemy")

Registering a name twice is still an error. If you worked around that for scripts which run more than once, you can now pass allow_existing as the third argument to get the existing registration:

local Enemy = world.register_new_component("script.my_game", "Enemy", true)

In Bevy’s component registry, script components are now named by their full path, i.e. script.my_game.Enemy.

types is deprecated

Use import_namespace with the crate that defines the type:

- local Transform = types.Transform
+ local Transform = import_namespace("bevy_transform").Transform

Script components are not added to types after a context is created. Import them from their namespace instead.

construct is stricter

construct (and the new Type.new) rejects unknown fields instead of ignoring them, and fills in missing fields from defaults.

Re-entering a running script is an error

Running a callback in a script context which is already running a callback (e.g. from an observer or a command flushed during the callback) now returns an error instead of deadlocking. Use queue_script_callback to run it once the context is free.

Rust

Messages renamed

Buffered BMS types are Bevy messages, and their names now say so:

0.220.23
ScriptCallbackEventScriptCallbackMessage
ScriptCallbackResponseEventScriptCallbackResponseMessage
ScriptErrorEventScriptErrorMessage
ScriptAttachedEventScriptAttachedMessage
ScriptDetachedEventScriptDetachedMessage
ScriptAssetModifiedEventScriptAssetModifiedMessage

ScriptingHandler::handle locks the context itself

Pass the context’s Arc instead of locking it:

- let mut context = context.lock();
- P::handle(args, &attachment, &label, &mut context, callbacks, world)
+ P::handle(args, &attachment, &label, &context, callbacks, world)

Pipeline progress functions renamed

0.220.23
num_processing_scriptsprocessing_script_count
processing_batch_completedis_processing_completed
num_loaded_scriptsloaded_script_count
progressprogress_fraction

World guard cache

WorldAccessGuard::setup_cache_raw takes two new arguments, the AppScriptCallbackRunners and the AppScriptTypeCatalogue. Prefer setup_cache(world, attachment), which reads them from the world. Use CurrentScriptAttachment::empty() for guards not tied to a running script.

Other

  • ScriptingSystemSet has a new variant, RunQueuedCallbacks.
  • The script function world.trigger_event (and WorldExtensions::trigger_event) applies all pending world commands before it returns, not only those of its observers.
  • Recipients moved to bevy_mod_scripting_script, and is re-exported from core::event. Resolving recipients is the GetRecipients trait.
  • AnyTypeRegistration has a fourth case, bundles (ScriptBundleRegistration).
  • ScriptComponentRegistration has a new public field, script_namespace.
  • WorldExtensions::register_script_component takes (namespace, name, allow_existing).
  • LAD files have new fields: namespace on types, Fields payloads, variant function namespaces, and default metadata. Custom LAD backends may need to handle them.