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.22 | 0.23 |
|---|---|
ScriptCallbackEvent | ScriptCallbackMessage |
ScriptCallbackResponseEvent | ScriptCallbackResponseMessage |
ScriptErrorEvent | ScriptErrorMessage |
ScriptAttachedEvent | ScriptAttachedMessage |
ScriptDetachedEvent | ScriptDetachedMessage |
ScriptAssetModifiedEvent | ScriptAssetModifiedMessage |
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.22 | 0.23 |
|---|---|
num_processing_scripts | processing_script_count |
processing_batch_completed | is_processing_completed |
num_loaded_scripts | loaded_script_count |
progress | progress_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
ScriptingSystemSethas a new variant,RunQueuedCallbacks.- The script function
world.trigger_event(andWorldExtensions::trigger_event) applies all pending world commands before it returns, not only those of its observers. Recipientsmoved tobevy_mod_scripting_script, and is re-exported fromcore::event. Resolving recipients is theGetRecipientstrait.AnyTypeRegistrationhas a fourth case, bundles (ScriptBundleRegistration).ScriptComponentRegistrationhas a new public field,script_namespace.WorldExtensions::register_script_componenttakes(namespace, name, allow_existing).- LAD files have new fields:
namespaceon types,Fieldspayloads, variant function namespaces, and default metadata. Custom LAD backends may need to handle them.