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

Installation

Cargo

First you need to install the crate by adding this entry to your Cargo.toml dependencies list:

bevy_mod_scripting = { version = "0.9.0", features = ["lua54"]}

Choose the language features you wish enabled and add them to the features block.

Bevy Plugin

The next step is to add the BMS plugin to your application.

app.add_plugins(BMSPlugin);

You can modify each of the plugins contained within the plugin group using set(MySubPlugin).

Language Features

Each language supported by BMS can be switched-on via feature flag as below:

LanguageFeature Flag
Lua51lua51
Lua52lua54
Lua53lua53
Lua54lua54
Luajitluajit
Luajit52luajit52
Luauluau
Runerune

Mobile

CI type-checks bevy_mod_scripting for aarch64-linux-android and aarch64-apple-ios; nothing is run on a device. Both need the target’s C toolchain (Android NDK, Xcode) as the Lua runtimes are built from source, and Android needs a bevy activity feature in your app (e.g. bevy/android-native-activity).

LanguageAndroidiOS
Lua51, Lua52, Lua53yesno: the Lua sources call system, which the iOS SDK marks unavailable (fixed upstream in Lua 5.4)
Lua54yesyes
Luajit, Luajit52yesno: luajit-src can’t build for iOS, which also forbids JIT
Luauyesyes
Runeyesyes

unsafe_lua_modules loads native libraries at runtime, which iOS restricts.

Extra Features

In order to fit as many use cases as possible, BMS allows you to disable a lot of its functionality.

By default all of the useful features are enabled, but you may disable them if you wish if you are only needing BMS for script lifecycle management, and want to populate the bindings yourself.

FeatureDescription
core_functionsIf enabled, will enable all core functions, i.e. bevy integrations which let you interact with Bevy via reflection
bevy_<bevy_crate>_bindingsenables bindings for the specified bevy crate, e.g. bevy_ecs, bevy_transform, bevy_pbr etc. for a full list of available modules check out The Cargo manifest
mlua_asyncEnables mlua/async
mlua_serializeEnables mlua/serialize
mlua_macrosEnables mlua/macros
unsafe_lua_modulesAllows loading unsafe modules via require in lua

Managing Scripts

Scripts live in the standard Bevy assets directory. Loading a script means obtaining its byte representation and associated language.

Evaluating a script means:

  • parsing the script body,
  • and creating or updating the resources which store script state (i.e. context)

Script attachments

Script attachments represent both the context in which a script “lives” and is executed, as well as its “residency identifier”.

Scripts can be attached either:

  • to an entity via ScriptComponent’s (i.e. ScriptAttachment::EntityScript)
  • or by being statically activated against their script assset (i.e. ScriptAttachment::StaticScript)

When you insert/remove ScriptComponent’s, ScriptAttachedMessage and ScriptDetachedMessage’s are sent and processed by the script pipeline.

Other attachments, like static scripts have to be manually triggered via AttachScript and DetachScript commands.

Loading

Scripts can be loaded into memory via the AssetServer.

let handle = asset_server.load::<ScriptAsset>("my_script.lua");

Or scripts can be created in memory.

let mut script = ScriptAsset::from("x = 0".into());
script.language = Language::Lua;
let handle = script_assets.add(script);

This will not evaluate any code yet.

Evaluating

A script does not participate in any callbacks until it is evaluated, to evaluate a script you must first attach it to an entity, or to a static script entry.

To evaluate a script, add it to a ScriptComponent manually attach it.

Load File via AssetServer

#![allow(unused)]
fn main() {
extern crate bevy;
extern crate bevy_mod_scripting;
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;

fn load_script(asset_server: Res<AssetServer>, mut commands: Commands) {
    let handle = asset_server.load::<ScriptAsset>("my_script.lua");
    commands.spawn(ScriptComponent(vec![handle]));
}
}

Prefer using strong asset handles, internal references will only persist weak versions of the handle, leaving you in control of the asset handle via the container component.

Create ScriptAsset and Add It

#![allow(unused)]
fn main() {
extern crate bevy;
extern crate bevy_mod_scripting;
use bevy::{asset::Assets, prelude::*};
use bevy_mod_scripting::prelude::*;

fn add_script(mut script_assets: ResMut<Assets<ScriptAsset>>, mut commands: Commands) {
    let content: String = "x = 0".into();
    let mut script = ScriptAsset::from(content);
    script.language = Language::Lua;
    let handle = script_assets.add(script);
    commands.spawn(ScriptComponent(vec![handle]));
}
}

Scripts added directly through assets, or via asset server without an asset path, will not contain path information, and logs will be slightly less useful.

Static Scripts

You can use attach and detach commands, which will run the script pipeline, repeatedly until the requested script attachments are processed. If you don’t want to incur big frametime slowdowns, you can instead send ScriptAttachedMessage and ScriptDetachedMessage manually, and let the pipeline pick these up as normal.

Attach a static script

#![allow(unused)]
fn main() {
extern crate bevy;
extern crate bevy_mod_scripting;
use bevy::{asset::Assets, prelude::*};
use bevy_mod_scripting::prelude::*;

fn add_static_script(mut asset_server: ResMut<AssetServer>, mut commands: Commands) {
    let handle = asset_server.load(script_path);
    commands.queue(AttachScript::<LuaScriptingPlugin>::new(
        ScriptAttachment::StaticScript(handle)
    ))
}
}

Detach a static script

#![allow(unused)]
fn main() {
extern crate bevy;
extern crate bevy_mod_scripting;
use bevy::{asset::Assets, prelude::*};
use bevy_mod_scripting::prelude::*;

fn remove_static_script(existing_handle: Local<Handle<ScriptAsset>>, mut commands: Commands) {
    commands.queue(DetachScript::<LuaScriptingPlugin>::new(
        ScriptAttachment::StaticScript(existing_handle)
    ))
}
}

Unloading

When you no longer need a script asset you can freely unload it as soon as it has been loaded, but the script attachment will persist. In order to trigger the on_script_unloaded etc. callbacks, you need to remove the script from the ScriptComponent or detach it manually via DetachScript if it’s static.

Once the last script in a context is removed, the context itself will also be removed.

Hot-loading scripts

To enable hot-loading of assets, you need to enable the necessary Bevy features as normal see the bevy cheatbook for instructions.

Assuming that hot-reloading is enabled for your app, any changes to script assets will automatically be picked up and the scripts re-loaded.

File Extensions

Normally the set of supported extensions is pre-decided by each language plugin.

I.e. Lua supports “.lua” extensions.

Scripts are mapped to the corresponding language plugin based on these and so it is important to use them correctly.

If you would like to add more extensions, you need to populate them via app.add_supported_script_extensions.

    app.add_supported_script_extensions(&[".pua"], Language::Lua);

Attaching Scripts

Once you have scripts discovered and loaded, you’ll want to run them.

At the moment BMS supports three methods of making scripts runnable:

  • Attaching them to entities via ScriptComponent’s
  • Adding static scripts
  • Creating dynamic systems ⚗️ (see the script systems section)

And then sending script event’s which trigger callbacks on the scripts.

Attaching scripts to entities

In order to attach a script and make it runnable simply add a ScriptComponent to an entity

    commands.entity(my_entity).insert(ScriptComponent::new(vec![my_script_handle, another_script_handle]));

In the script, import_namespace("bms").current_entity() returns the entity the script is attached to.

Be wary of path separators, by default script ID's are derived from asset paths, which are platform dependent. Make sure to use `std::path::PathBuf` if you are targetting multiple platforms.

Making static scripts runnable

Some scripts do not require attaching to an entity. You can run these scripts by loading them first as you would with any other script, then either adding them by issuing a AttachScript command like so:

    commands.queue(AttachScript::new(script_attachment));

The script will then be run as any other script but without being attached to any entity.

Running Scripts

Scripts can run logic either when loaded or when triggered by an event. For example the script:

print("hello from load time")
function on_event(arg1)
    print("hello from event time")
    print(arg1)
end

Will print “hello from load time” when the script is loaded, and “hello from event time” when the script receives an event targeting the on_event callback with a receiver list including this script or entity.

In order to trigger on_event you need to first define a label, then send an event containing the label:


#[derive(Reflect)]
pub struct MyReflectType;

// define the label, you can define as many as you like here
callback_labels!(OnEvent => "on_event");

// trigger the event
fn send_event(mut writer: EventWriter<ScriptCallbackMessage>) {
    // allocated values live as long as references to them
    let my_reflect_payload = ReflectReference::new_allocated(MyReflectType);

    writer.send(ScriptCallbackMessage::new_for_all_scripts(
        OnEvent,
        vec![my_reflect_payload.into()],
    ));
}

Note the second argument is the payload we are sending with the event, in this case we are sending an arbitrary reflect type MyReflectType. This can be any type you like, as long as it implements Reflect.

Other variants of the ScriptValue enum are available for sending different types of data, such as ScriptValue::Integer for primtive, types.

Event Handlers

In order for the events you send to actually be picked up, you need to inject special systems into your application. These systems will listen for the events and trigger the appropriate callbacks on the scripts:

app.add_systems(Update, event_handler::<OnEvent, LuaScriptingPlugin>);

Note the system is parameterized by the label we defined earlier, and the scripting plugin we are using. You can add as many of these systems as you like.

The event handler will catch all events with the label OnEvent and trigger the on_event callback on all targeted scripts which have that callback defined.

In order to handle events in the same frame and not accidentally have events “spill over” into the next frame, you should make sure to order any systems which produce these events before the event handler systems.

Commands

You can also use manually issued RunScriptCallback commands to trigger script callbacks as well. These must be run from a exclusive system, or via a any other system but with limited access to the world (See the WithWorldGuard system param, which will allow you to create a WorldGuard and use it to run the commands)

Controlling Script Bindings

In this book we refer to anything accessible by a script, which allows it to communicate with your Rust code a binding (which in previous versions was more generically referred to as a script API).

The “binding” here being used as in: binding script code to rust code.

Namespaces

Namespaces are a way to group functions together, and are used to prevent naming conflicts. You can have multiple namespaces, and each namespace can have multiple functions.

Language implementations will also look for specific functions registered on your type first before looking at the generic ReflectReference namespace.

Dynamic Functions

Everything callable by scripts must first be registered in the dynamic function registry. Notably we do not make use of the normal bevy function registry to improve performance and usability. This means you cannot call just any function.

In order for a function to be callable by a script it must adhere to a few requirements:

  • Each argument must implement FromScript.
  • Each return type must implement IntoScript.
  • Each argument must also implement GetTypeDependencies
  • Each return type must also implement GetTypeDependencies

The into/from requirements allow us to convert these types to ScriptValue’s, and each supported scripting language can then marshall these into the script.

Note these types are implemented for primitives, but if you want to interact with one of your Reflect implementing types, you will need to use one of R<T>, M<T> or V<T> wrappers in place of &T, &mut T and T respectively.

These wrappers enable us to safely interact with bevy, and claim any necessary mutex’es on Resources, Components or Allocations.

The GetTypeDependencies, trait is simply a local trait alias for GetTypeRegistration with less strict type requirements. It allows us to register all the types necessary for the function calls, so that you don’t have to register anything manually. If your type implements GetTypeRegistration you should not face any issues on this front.

Registering Script Functions

Registering functions can be done via the NamespaceBuilder like below:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "hello_world",
            |s: String| {
                println!(s)
            },
        );

    NamespaceBuilder::<GlobalNamespace>::new_unregistered(&mut world)
        .register(
            "hello_world2",
            |s: String| {
                println!(s)
            },
        );

This will allow you to call this function within lua like so:

some_type:hello_world("hi from method!");
hello_world2("hi from global!");

Note the new_unregistered call instead of new, this is because GlobalNamespace is not a Reflect type, and the new call also automatically registers the type in the reflection registry.

Macros

The above is a bit tedious, so instead you can use the script_bindings macro, which applies to impl blocks like so:

#[script_bindings(name = "test_fn")]
impl TestStruct {
    /// My docs !!
    /// 
    /// Arguments:
    /// * `_self` - the first argument
    /// * `arg1` - the second argument
    /// Returns:
    /// * `return` - nothing
    fn test_fn(_self: R<TestStruct>, mut arg1: usize) {}
}


pub fn main() {
    let mut app = App::new();
    register_test_fn(app.world_mut())
}

Note the documentation will automatically be picked up and stored for the purposes of reflection and documentation generation, including argument/return type specific docs.

Deriving FromScript and IntoScript

Generally all reflect types are wrapped in: R<T> V<T> or M<T> when writing script bindings. However some types may opt in to implement FromScript or IntoScript directly.

Doing this requires implementing a set of other traits which tell the runtime how to manage your type in conversion and function dispatch.

The most trivial way to allow your type to be used directly in bindings is to apply derive macros like so:

#![allow(unused)]
fn main() {
#[derive(Reflect, ScriptType)]
pub struct MyThing(usize);


#[script_bindings(remote)]
impl MyThing {
    // Can now be used directly without V<> wrapper, acts exactly like V<MyThing>
    pub fn test(thing: MyThing) -> MyThing {
        thing
    }
}
}

ScriptType implements FromScript, IntoScript, ArgMeta, GetTypeDependencies and TypedThrough at once, converting through V<Self>.

If you wish to customize one of the conversions, write that impl by hand and use #[script_type(from = custom)] or #[script_type(into = custom)]. This skips the generated impl and documents the type as opaque in generated docs. See the custom conversions example for more information.

Context Arguments

Each script function call always receives an additional context argument: FunctionCallContext. You can opt-in to receive this argument in your own function definitions by adding it as the first argument.

The context contains requests from the caller to your function, such as “I am calling you from a 1-indexed array system, please convert the index first”, This argument is only relevant if you’re targeting multiple languages.

It also allows you to retrieve the world via FunctionCallContext::world().

You can use this as follows:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "hello_world",
            |ctx: FunctionCallContext, s: String| {
                let world = ctx.world()?;
                let should_use_0_indexing = ctx.convert_to_0_indexed;
                println!(should_use_0_indexing);
                println!(s)
                Ok(())
            },
        );

Generic Arguments

Sometimes you might want to be generic over the type of argument you’re accepting, you can do so by accepting ScriptValue arguments like so:

    NamespaceBuilder::<ReflectReference>::new(&mut world)
        .register(
            "is_integer",
            |s: ScriptValue| {
                match s {
                    ScriptValue::Integer(i) => true,
                    _ => false
                }
            },
        );

You can treat return values similarly.

Fallible functions

Your script functions can return errors either by:

  • Returning Result<T: IntoScript, InteropError>
  • Returning ScriptValue and manually creating the ScriptValue::Error(into_interop_erorr.into()) variant.

Reserved Functions

There are a few reserved functions that you can override by registering them on a specific type:

Function NameDescriptionOverridable?Has Default Implementation?
geta getter function, used for indexing into a type❌✅
seta setter function, used for setting a value on a type❌✅
suba subtraction function, used for subtracting two values✅❌
addan addition function, used for adding two values✅❌
mula multiplication function, used for multiplying two values✅❌
diva division function, used for dividing two values✅❌
rema remainder function, used for getting the remainder of two values✅❌
nega negation function, used for negating a value✅❌
powa power function, used for raising a value to a power✅❌
rsub, rdiv, rrem, rpowthe reflected sub, div, rem and pow, called on the right operand when the left one is not a value, i.e. 1 - v calls rsub(v, 1). add and mul are called with their operands swapped instead✅❌
eqan equality function, used for checking if two values are equal✅❌
lta less than function, used for checking if a value is less than another✅❌
iteran iterator function, used for iterating over a value❌✅
displaya display function, used for pretty printing values❌*✅
debuga display function, used for displaying the internals of a value❌*✅

* - You can register an instance of ReflectDisplayWithTypeInfo type data on Reflect implementing types to override their printing behavior

In this context overridable indicates whether language implementations will look for a specific function on your type before looking at the generic ReflectReference namespace. You can still remove the existing registration for these functions on the ReflectReference namespace if you want to replace them with your own implementation.

Note the ReflectReference namespace is special, in that functions defined on it, act like a fallback and hence apply to ALL references.

Where functions can live

The type in the impl block you apply script_bindings to (or the one passed to NamespaceBuilder) decides where the functions are available:

impl targetAvailable onReceives
MyTypeMyType values and the MyType type, as imported from its namespacewhatever you declare
ReflectReferenceevery value, after MyType’s own functionsthe value
StaticTypeRefevery type, after MyType’s own functionsthe type, filled in automatically
NamespaceMembersthe namespace given by namespace = "...", i.e. import_namespace("my_game")whatever you declare
GlobalNamespacethe builtin globals, i.e. no prefixwhatever you declare

When the same name exists in more than one place, the most specific one wins. For ReflectReference and StaticTypeRef in a script_bindings block outside of the crate defining them, use the remote attribute.

Functions available on every type

The StaticTypeRef namespace is the equivalent for types, i.e. Vec3 in Vec3.new(..). Functions registered on it are available on every type, and receive the type as their first argument, which is filled in automatically:

NamespaceBuilder::<StaticTypeRef>::new(app.world_mut()).register(
    "describe",
    |ctxt: FunctionCallContext, type_ref: V<StaticTypeRef>| -> Result<String, InteropError> {
        Ok(type_ref.type_info(&ctxt.world()?)?.type_path().to_string())
    },
);
local Vec3 = import_namespace("math").Vec3
print(Vec3.describe()) -- "glam::Vec3"

A function registered on the type itself always takes priority over one on StaticTypeRef. The new constructor is implemented this way, see Constructing Arbitrary Types.

Signatures which depend on the type

A shared function’s signature can refer to the type it is bound to, using the placeholder types BoundValue (a value of the type), BoundFields (a table of the type’s fields) and BoundHandle (a handle to an asset of the type). Wherever the function is bound to a type, these are replaced with the type, so the documentation and the Lua language server files show, for example, MyStruct.new(payload: MyStruct.Fields): MyStruct rather than a generic table and reference, or Image.load(path: string): Handle<Image>. Functions using BoundHandle are only documented on asset types, i.e. types registered with register_asset_reflect. The same placeholders work for functions on EnumVariantRef, which are bound to each variant of each enum when the LAD file is built (as functions in the Variant namespace). Placeholders left unbound are documented as what they are at runtime, a ReflectReference and a table.

The enum variants of a type are also available on the type, i.e. MyEnum.Variant, after the functions.

Namespace members

Each type registered with the type registry is an entry in the table import_namespace returns for its namespace, i.e. import_namespace("math").Vec3.

Functions which don’t belong to a type are members of a namespace, declared on impl NamespaceMembers:

#[script_bindings(namespace = "my_game")]
impl NamespaceMembers {
    fn spawn_enemy(health: f32) { /* ... */ }
}
local my_game = import_namespace("my_game")
my_game.spawn_enemy(5.0)

Values are registered per namespace with AppScriptNamespaceMembers::register_value, and are made each time the namespace is imported.

The only globals are the builtins: import_namespace, export_namespace and register_callback. world is in the bms namespace: import_namespace("bms").world.

Types are not globals, which keeps types with the same name from shadowing each other. Use the filter of CoreScriptGlobalsPlugin to choose which types scripts can look up by name.

Modifying Script Contexts

You should be able to achieve what you need by registering script functions in most cases. However sometimes you might want to override the way contexts are loaded, or how the runtime is initialized.

This is possible using Context Initializers and Context Pre Handling Initializers as well as Runtime Initializers.

It is however always reccomened to use the dynamic script function registry whenever possible, as it is more flexible and easier to use. It also allows you to introspect available functions easier.

Context Initializers

For example, let’s say you want to set a dynamic amount of globals in your script, depending on some setting in your app.

You could do this by customizing the scripting plugin:

let plugin = LuaScriptingPlugin::default().add_context_initializer(|_context_key: &ContextKey, context: &mut Lua| {
    let globals = context.globals();
    for i in 0..10 {
        globals.set(i, i);
    }
    Ok(())
});

app.add_plugins(plugin)

The above will run every time the script is loaded or re-loaded and before it handles any callbacks.

Context Pre Handling Initializers

If you want to customize your context before every time it’s about to handle events (and when it’s loaded + reloaded), you can use Context Pre Handling Initializers:

#![allow(unused)]
fn main() {
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;
fn scripting_plugin(app: &mut App) {
    app.add_plugins(LuaScriptingPlugin::default()
                       .add_context_pre_handling_initializer(|context_key: &ContextKey, context: &mut Lua| {
        let globals = context.globals();
        if let Some(script_id) = context_key.script_id.as_ref() {
            globals.set("script_name", script_id.to_owned());
        }
        Ok(())
    }));
}
}

Runtime Initializers

Some scripting languages, have the concept of a runtime. This is a global object which is shared between all contexts. You can customize this object using Runtime Initializers:

#![allow(unused)]
fn main() {
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;
fn scripting_plugin(app: &mut App) {
    app.add_plugin(SomeScriptingPlugin::default().add_runtime_initializer(|runtime: &mut Runtime| {
        runtime.set_max_stack_size(1000);
        Ok(())
    }));
    
}
}

In the case of Lua, the runtime type is () i.e. This is because mlua does not have a separate runtime concept.

Accessing the World in Initializers

You can access the world in these initializers by using the thread local: ThreadWorldContainer:

#![allow(unused)]
fn main() {
use bevy::prelude::*;
use bevy_mod_scripting::prelude::*;
fn scripting_plugin(app: &mut App) {
    let plugin = LuaScriptingPlugin::default();
    plugin.add_context_initializer(|_context_key: &ContextKey, context: &mut Lua| {
        let world = ThreadWorldContainer.try_get_world().unwrap();
        world.with_resource::<MyResource>(|res| println!("My resource: {:?}", res));
        Ok(())
    });
    app.add_plugins(plugin);
}
}

Contexts

Each script runs in a context. By default BMS will create an individual context, or sandbox, for each script-entity pair that is run. This means that each script-entity pair will have its own set of global variables and functions that are isolated from other scripts. However, sometimes this might not be desirable. If you are not worried about scripts interfering with each other, or if you want to easily share data between scripts, you can consider using a different context policy.

Context Policies

Shared Context

A shared context means that all scripts run in the same context; there is in fact only one context to run in. If the scripts interact heavily with each other, this may be what you want.

To enable a shared context, set the corresponding context policy on the scripting plugin:

app.add_plugins(LuaScriptingPlugin::default().set_context_policy(
    ContextPolicy::shared(),
));

Shared contexts require your scripts to be more careful about how they register callbacks due to the nature of top level functions belonging to the “currently loaded” global script. See the callbacks section

Per Script Context

A per script context provides each script with their own context. However, scripts may be attached to multiple entities, in which case a single script context is shared by multiple entities.

To enable per script contexts, insert the ContextPolicy::per_script() resource.

app.add_plugins(LuaScriptingPlugin::default().set_context_policy(
    ContextPolicy::per_script(),
));

Per Entity Context

A per entity context provides each entity with their own context. The scripts attached to an entity via ScriptComponent all run in the same context.

To enable per entity contexts, insert the ContextPolicy::per_entity() resource.

app.add_plugins(LuaScriptingPlugin::default().set_context_policy(
    ContextPolicy::per_entity(),
));

Per Entity and Script Context

A per entity-and-script context provides each entity-script pair with their own context. This is a maximally isolated way to run scripts.

To enable per entity-and-script contexts, insert the ContextPolicy::per_entity_and_script() resource.

app.add_plugins(LuaScriptingPlugin::default().set_context_policy(
    ContextPolicy::per_entity_and_script(),
));

Custom Policies

Here is another way to write the per_script() policy.

let policy_a = ContextPolicy::per_script();
let policy_b = ContextPolicy { priorities: vec![ContextRule::Script, ContextRule::Shared] };
assert_eq!(policy_a, policy_b);

Reminding ourselves how ContextKey is defined,

pub struct ContextKey {
    pub entity: Option<Entity>,
    pub script: Option<Handle<ScriptAsset>>,
}

we read policy_b like this: if ContextKey has a script, return a ContextKey with only a script. Failing that ContextRule::Shared always returns an empty ContextKey.

One may also provide an entirely custom rule by implementing the ContextKeySelector trait.

Context Loading Settings

All context loading settings are stored in a separate resource per scripting plugin namely: ContextLoadingSettings<Plugin>.

The settings are as follows:

  • loader - the load and unload strategy for contexts. Each scripting plugin will have a load and unload function which is hooked up through here
  • context_initializers - stores all context initializers for the plugin
  • context_pre_handling_initializers - stores all context pre-handling initializers for the plugin

More advanced applications might want to customize these settings to suit their needs.

Callbacks

Callbacks generally refer to hooks called either manually or via rust event handlers, on scripts which can choose to subscribe to them.

Callbacks come in two variants:

  • Freestanding, top level functions
  • Registered, or “frozen” callbacks

Freestanding callbacks

An example of a freestanding callback:

function on_script_loaded()
    print("doing things")
end

this callback is refered to by “name”, and on the rust side can be invoked either via RunScriptCallback command, or by setting up an event handler system which passes on ScriptCallbackMessage’s to scripts.

The key thing to note about this type of callback, is that if the script is ever reloaded, and the contents of this callback change, the logic inside it will also be hot-reloaded.

Registerd Callbacks

You can also register a callback like so:

register_callback("on_script_loaded", my_registered_callback)

function my_registered_callback()
    print("doing things")
end 

Registered callbacks, take priority over freestanding ones, and contrary to freestanding callbacks, they are “frozen”. I.e. once a callback is registereed in this manner, hot reloads won’t affect the logic inside them.

This works well when using shared contexts, where scripts will overwrite top level functions when being loaded. You can use the on_script_loaded callback to register all your scripts callbacks while they are loaded as top level functions, and when future loads happen, every callback will be issued correctly.

This functionality is implemented at script plugin level, so some languages might not support this. All core languages do however.

Script Systems

Script systems are an experimental feature

It’s possible within BMS to inject new systems from within scripts themselves.

Systems introduced by scripts can run in parallel to other systems, and can be freely inserted between any other system, including other script systems.

BMS also provides utilities for visualising schedules using dot graphs, allowing low-effort modding frameworks for game authors.

Schedules

Bevy doesn’t support reflecting schedules, so BMS rolls it’s own schedule registry resource: AppScheduleRegistry, which can be used to add any custom schedules you want to interact with. The default Bevy schedules will be pre-populated for you.

Once you’ve registered your schedule you will be able to interact with it in scripts like below:

local world = import_namespace("bms").world
local update_schedule = world.get_schedule_by_name("Update")
local systems = update:systems()
local system_with_name = update:get_system_by_name("my_system")

Inserting Systems

To insert a system you will need to use bms.system_builder like below:

local bms = import_namespace("bms")
local attachment = bms.ScriptAttachment.new_entity_script(bms.current_entity(), bms.current_script())
local system = bms.system_builder("my_system", attachment)
    :exclusive()
    :after(some_other_system)
    :before(another_system)

This will let you call world.add_system like so:

local world = import_namespace("bms").world
world.add_system(update_schedule,system)

Ordering and sets

Besides systems (after/before), script systems can be ordered against:

  • other script systems, by callback label and script, which must have been added before: :after_script_system("on_physics", attachment)
  • sets: :after_set(set), :before_set(set), and put in sets: :in_set(set)

Scripts register their own sets into a script.* namespace, i.e. to group and order the systems of a mod. A set is removed from its namespace when its script unloads, registering it again gives the same set:

local ai = world.register_new_system_set("script.my_mod", "ai")
-- other scripts: import_namespace("script.my_mod").ai

Rust sets the game registers are members of their namespace, the BMS bindings register the main Bevy sets (i.e. transform.TransformSystems.Propagate, time.TimeSystems):

app.register_script_system_set("transform.TransformSystems", "Propagate", TransformSystems::Propagate);
local propagate = import_namespace("transform.TransformSystems").Propagate
builder:in_set(ai):after_set(propagate)

world.get_system_set_by_name finds either kind by its full name, i.e. "transform.TransformSystems.Propagate" or "script.my_mod.ai".

Run conditions

:run_if only runs the system if the condition holds, conditions are evaluated in Rust without calling the script. Every condition passed to run_if must hold:

local c = bms.conditions
builder:run_if(c.any_with_component(Enemy))
       :run_if(c.not_(c.resource_exists(Paused)))
       :run_if(c.on_timer(0.5))

Conditions: resource_exists, resource_changed, resource_added, any_with_component, on_timer(seconds), run_once and the combinators not_, and_, or_ (named so as not, and, or are Lua keywords).

Lifetime

A script system is identified by its attachment and callback label: adding it again replaces the old one (with a warning). Script systems are removed when their script unloads or reloads, a reloading script adds them again in on_script_loaded.

Bevy cannot change a schedule while it runs, i.e. PreUpdate where scripts are loaded. Systems added to (or removed from) a running schedule are added (or removed) once it finishes, removed systems stop running right away. world.add_system then returns a system which can be used for ordering, but has no node in the schedule yet.

Errors in script systems are sent as ScriptErrorMessages, like those of other callbacks.

Parameters

The system builder allows script authors to parameterise systems, using resource and query functions. The order in which those functions are called, will define the order in which arguments will be provided to the specified script callback.

For example:

local bms = import_namespace("bms")
local world = bms.world
bms.system_builder("my_system")
    :query(
        world.query()
            :component(ComponentA)
            :component(ComponentB)
            :with(ComponentC)
            :without(ComponentD)
    )
    :resource(ResourceA)

will create a system which calls the specified callback my_system with 2 arguments:

  • The results of the query, each a list of the entity followed by the components in the order they were added: {entity, a, b}
  • The ReflectReference to ResourceA
function my_system(results, resource_a)
    for _, result in ipairs(results) do
        local entity, a, b = result[1], result[2], result[3]
    end
end

resource and component give read and write access. Use resource_read and component_read for read only access, systems reading the same resources and components can run in parallel, while systems writing them cannot:

bms.system_builder("my_system", attachment)
    :query(world.query():component_read(ComponentA):component(ComponentB))
    :resource_read(Time)

Queries can also retrieve components entities don’t need to have (optional, optional_read, nil for entities without them), and only match entities whose components were added or changed since the system last ran (added, changed, filters like with). Outside of systems, added and changed are relative to the last app update:

world.query()
    :component(Transform)
    :optional_read(Velocity)
    :changed(Health)

Queries of a system may access the same components if they can’t match the same entities, i.e. component(A):with(B) and component(A):without(B), otherwise the system reports an error and doesn’t run.

Exclusive systems

An exclusive system can be created using the exclusive function call on the system builder.

This allows the system to access everything as in a normal event handler.

Non-exclusive systems, will only be able to access the set of components and resources as parameterized when building the system. This is why we can run the system in parallel to other non-overlapping systems.

Components are only accessible on the entities matched by the queries declaring them, i.e. with world.query():component(A):with(B) the system can’t access A on entities without B, since Bevy runs it in parallel with systems accessing A on those. Components only used as filters (with, without) can’t be accessed.

Exclusive systems on the other hand, cannot run in parallel.

Callback

The system injected will be similar to an event handler, however it will only trigger the specified script, and without any entity, in the first example you’d see the following lua callback:

function my_system()
    print("I am a dynamic system")
end

get triggered every update.

Examples

In the future we hope to embedd live WASM code examples into the documentation, for now the best source of example scripts will be our regression test suite available in all supported languages in our github repository.

For rust examples see this folder.

Scripting IDE Integrations

LADfiles

LADfiles

BMS provides a custom Language Agnostic Declaration format (LAD), which can be used to integrate with other tooling.

If you use #[script_bindings] macros, these files will magically contain your code comments, bindings as well as everything else required to drive other powerful integrations.

The declaration file is generated from the type registry and serves as a light abstraction layer simplifying the traversal of all available types, namespaces and functions.

You can customize how / where and if these files are stored using the main BMS plugin group:

    app.add_plugins(BMSPlugin.set::<ScriptingFilesGenerationPlugin>(
        ScriptingFilesGenerationPlugin::new(
            true, // enabled, you can use a compilation feature to disable this here
            PathBuf::from("assets").join("definitions"),
            Some(PathBuf::from("bindings.lad.json")), // do also save the ladfile itself
            "Core BMS framework bindings",
            true,
            true,
        ),
    ));

This plugin is only available when one of the sub features (like lua_language_server_files) mentioned in this chapter is enabled.

You might not want to run this pipeline in your final binary, but rather bundle some of the generated files into some sort of development pack for modding. You can use compiler flags like #[cfg(not(debug_assertions))] to disable ladfile generation at runtime, or simply disable the lower level features within BMS to avoid compiling related dependencies too.

Lua Language Server

This feature is in early stages, the definitions provide 90% of the way there, but there are rough edges that will need to be worked out

Luals or LLS, is an open source language server which integrates with many IDE’s.

It is powered by lua specific annotation or definition files which BMS can generate directly from its own LADfiles.

To enable this simply enable the lua_language_server_files feature, and a bindings.d.lua definition file, plus a bindings.<namespace>.d.lua file per namespace, will be generated in the LADfile output directory in the Startup schedule.

Script writers can then use this generated file by pointing their .luarc.json file to these definitions:

{
    "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/master/setting/schema.json",
    "workspace.library": [
        "assets/definitions"
    ],
    "runtime.version": "Lua 5.4",
    "hint.enable": false,
    "workspace.preloadFileSize": 10000
}

The generated definitions file is large (over a megabyte with the default bindings), and the language server skips Lua files bigger than workspace.preloadFileSize (in KB, 500 by default). If completions for BMS types are missing, i.e. Vec3. suggests nothing, raise this limit above the size of the generated file and restart the language server.

Script Pipeline

Processing script atachments and detachments is all done by the script pipeline.

In versions prior to 16.0 the pipeline was represented by load unload commands, which atomically processed scripts. Since then the pipeline has been maassively overhauled to allow:

  • Customizing callbacks during the process
  • Budgeting the work done by the pipeline each frame
  • Allowing async steps in the process

The new pipeline works like this:

  • A set of systems in PreUpdate “filter” incoming ScriptLifecycleMessage’s (attachments and detachments, processed in the order they were written) as well as ScriptAssetModifiedMessage’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.
  • A set of other systems then converts those into active ScriptMachine’s
  • Then inside the ScriptProcessingSchedule<P>, which is only run in PreUpdate if there are active machines, we tick each machine until it either errors or reaches its final state.

Script Machines

State Machine

Script loading is handled by the following state machines:

graph TD;
    A[Loading Initialized]
    B[Reloading Initialized 
Enter: OnReloaded callback]

    A --[ new context ]--> C
    B --[ existing context]--> C
    C[Context Assigned
Enter: OnReloaded + OnLoaded callbacks]

    C --> D

    D[Loading Completed]

    E[Unloading Initialized
Enter: OnUnloaded callback]
    F[Context Removed]
    G[Resident Removed]
    E --[Last resident]--> F
    E --[More residents]--> G
    H[Unlading Completed]
    F --> H
    G --> H

Hooks, such as on_script_loaded are implemented using bevy observers. This allows you to hook into various parts of the loading process and add your own callbacks, i.e.:

fn main(&mut app: App) {
    let machines = app.add_observer(|On<LoadingCompleted<LuaScriptingPlugin>>| todo!("do stuff"));
}

Timing & Order

By default all machines are ticked to completion in the frame they start. Setting ScriptLoadingPipeline::tick_budget limits the amount of machine ticks (steps in the state machine above) per frame, spreading the loading of many scripts over multiple frames. The budget counts steps, not time, so a step running a slow callback can still take up the frame.

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.

The script loading/unloading order will look as follows:

  • the order in which components are attached/detached, will determing what order scripts will be processed
  • an attachment whose script asset is still loading holds back the attachments and detachments after it, until it finishes loading
  • scripts are processed one-by-one, i.e. each machine is ticked to completion before the next one is started
    • meaning for example if two scripts are loaded, their on_script_loaded hooks will not run at the same “lockstep”.
  • loading/unloading might happen over multiple frames, depending on the pipeline’s settings.

Determinism

Given the same inputs (the same order of attachments, detachments and app updates), scripts load in the same order and callbacks reach scripts in the same order, on every run and machine: script contexts are kept in insertion ordered maps, and the pipeline budget counts steps rather than time.

What BMS cannot control:

  • which frame a script asset finishes loading in, as asset IO is asynchronous. Wait for scripts to load (see below) before relying on frame timing.
  • language internals, for example Lua iterates tables with string keys (pairs) in a different order on each run. BMS seeds Lua’s math.random with 0 when creating a context, call math.randomseed to change it.

Waiting for scripts to load

In order to check on the pipeline and figure out when everything is ready, you can use the ScriptPipelineState<P> system parameter in a system as shown in the script_loading example.

Release Notes

This section contains migration guides and release notes relevant to the bevy_mod_scripting crate.

This used to live in the repository, so for older release notes or guides, refer to the GitHub repository

Migration Guide: 0.13 to 0.14-alpha or 0.14 to 0.15

The most important changes to be aware of in this release are:

  • BMS now uses Handle<ScriptAsset> as its principle means of referring to scripts as opposed to the ScriptId that was used previously.

  • BMS exposes many more choices for deciding how scripts are associated with the contexts in which they run.

  • script_id is replaced with script_asset which now has a type of Handle<ScriptAsset>.

Handles

The use of handles for scripts is perhaps the biggest user-facing change. It makes BMS asset usage follow Bevy’s conventions. It requires less configuration. It is more idiomatic.

ScriptComponent Change

In prior versions, ScriptComponent accepted a vector of ScriptIds, which was a type alias for Cow<'static, str>.

-pub struct ScriptComponent(pub Vec<Cow<'static, str>>);
+pub struct ScriptComponent(pub Vec<Handle<ScriptAsset>>);

Because ScriptComponent accepts handles, it is no longer necessary to store the handles somewhere to prevent the script from unloading. Nor is it necessary to configure an asset path to script id mapper.

ScriptComponent(vec![asset_server.load("foo.lua")])

It is still beneficial to retain script assets in memory, for certain features to work. For example, script_asset will not be able to retrieve the asset path of the script if it’s not retained.

ScriptId Change

The ScriptId has changed from being a string to being an asset ID.

-type ScriptId = Cow<'static, str>
+type ScriptId = AssetId<ScriptAsset>

No Evaluation on Load

In prior versions, BMS would immediately evaluate a ScriptAsset when it was loaded, and if multiple script assets were loaded, they would be evaluated in non-deterministic order. (See issue #426.) Script assets no longer evaluate immediately. Script assets are only evaluated when their handles are added to a ScriptComponent or they are added to StaticScripts.

In addition when a ScriptComponent loads its scripts, it loads them sequentially.

ScriptAssetSettings Removed

The ScriptAssetSettings has been removed. Let us address each of its fields in turn.

script_id_mapper

See AssetPathToScriptIdMapper section.

extension_to_language_map and supported_extensions

This is now represented by the LanguageExtensions resource, which can be configured directly during initialization

pub struct LanguageExtensions(HashMap<&'static str, Language>);

or by the ConfigureScriptAssetSettings trait:

app.add_supported_script_extensions(&["p8lua"], Language::Lua);

In addition one can configure the language of an asset when it is loaded:

asset_server.load_with_settings("hello.p8lua", |settings: &mut ScriptSettings| {
   settings.language = Some(Language::Lua);
});

or when it is created:

let content = String::from("x = 0");
let mut script = ScriptAsset::from(content);
script.language = Language::Lua;

ScriptMetadata and ScriptMetadataStore Removed

These were present to associate the previous ScriptId with the asset ID and language. That is no longer necessary as the ScriptAsset knows its own language.

pub struct ScriptAsset {
    /// The body of the script
    pub content: Box<[u8]>,
    /// The language of the script
    pub language: Language,
}

AssetPathToScriptIdMapper Removed

No mapper is necessary between a script and a script ID. If you have a script handle, you have its script ID

let handle: Handle<ScriptAsset> = ...;
let script_id: ScriptId = handle.id(); // ScriptId = AssetId<ScriptAsset>

and vice versa.

let script_id: ScriptId = ...;
let handle: Handle<ScriptAsset> = Handle::Weak(script_id);

Contexts

Choosing how scripts run is a big policy decision. Previously BMS had two options:

  • Each script ran in its own context.
  • All scripts ran in one context.

This was controlled by the enable_context_sharing() method on ConfigureScriptPlugin. That function is now deprecated. Instead use the set_context_policy method:

app.add_plugins(LuaScriptingPlugin::default().set_context_policy(
    ContextPolicy::shared(),
));

The reason for this change is there are many more choices than before, namely:

  • ContextPolicy::shared()
  • ContextPolicy::per_script()
  • ContextPolicy::per_entity()
  • ContextPolicy::per_entity_and_script()

See Contexts for more information.

ContextKey Added

Previously BMS used a ScriptId and sometimes an Entity to refer to a context. If there was no entity then Entity::from_raw(0) was used. Instead BMS now uses this ContextKey to look up contexts.

pub struct ContextKey {
    /// Entity if there is one.
    pub entity: Option<Entity>,
    /// Script ID if there is one.
    pub script_id: Option<Handle<ScriptAsset>>
}

This change affects the parameters for the context_pre_handling_initializers

- context_pre_handling_initializers: vec![|script_id, entity, context| {
+ context_pre_handling_initializers: vec![|context_key, context| {

and context_initializers:

- context_initializers: vec![|script_id, context| {
+ context_initializers: vec![|context_key, context| {

Recipients Changes

The Recipients enum now looks like this:

#[derive(Clone, Debug)]
pub enum Recipients {
    /// The event needs to be handled by all scripts, if multiple scripts share a context, the event will be sent once per script in the context.
    AllScripts,
    /// The event is to be handled by all unique contexts, i.e. if two scripts share the same context, the event will be sent only once per the context.
    AllContexts,
    /// The event is to be handled by a specific script-entity pair
    ScriptEntity(ScriptId, Entity),
    /// the event is to be handled by a specific static script
    StaticScript(ScriptId),
}

This aligns with how scripts are associated with contexts better.

ScriptCallbackEvent changes

The language for recipients is now controlled through the language field of the ScriptCallbackEvent. This allows for more flexibility in how callbacks are handled, especially when multiple languages are involved.

If no language is specified, the callback will apply to all languages.

#[derive(Clone, Event, Debug)]
#[non_exhaustive]
pub struct ScriptCallbackEvent {
    /// The label of the callback
    pub label: CallbackLabel,
    /// The recipients of the callback
    pub recipients: Recipients,
    /// The language of the callback, if unspecified will apply to all languages
+   pub language: Option<Language>
    /// The arguments to the callback
    pub args: Vec<ScriptValue>,
    /// Whether the callback should emit a response event
    pub trigger_response: bool,
}

Bindings Changes

ScriptId

script_id is replaced with script_asset which now has a type of Handle<ScriptAsset>. This means that you can no longer use a string to refer to a script, but rather you must use a handle.

Scripts can still access the asset path of the script using:

-- prints: "my_script.lua"
print(script_asset:asset_path())

ScriptAttachment

The concept of script attachments has been introduced to describe the idea of a script instance. Previously this was muddied due to the fact script ID’s were the primary way to refer to scripts. Now the instance of a script and its mapping to a context is clearer.

This is reflected in a brand new set of bindings:

-- will create backing ScriptAttachment instances, that can be used in other bindings.
local entity_script = ScriptAttachment.new_entity_script(entity, script_asset)
local static_script = ScriptAttachment.new_static_script(script_asset)

System Builder

the system builder no longer accepts script id’s as parameters. Instead it accepts script attachments

-system_builder("my_callback", "this_script_id.lua")
+system_builder("my_callback", ScriptAttachment.new_static_script(script_asset))

0.15.0 - Asset Handles and Context Policies

This release focuses on aligning bevy_mod_scripting with modern Bevy practices, most notably by switching to Handle<ScriptAsset> for script management. This change simplifies the API, removes boilerplate, and makes script handling more idiomatic.

Summary

Asset-First Workflow

Scripts are now treated as first-class Bevy assets. The old ScriptId (which was a string) has been replaced by AssetId<ScriptAsset>, and you’ll primarily interact with scripts via Handle<ScriptAsset>.

// New way
let handle: Handle<ScriptAsset> = asset_server.load("my_script.lua");
commands.spawn(ScriptComponent(vec![handle]));

Scripts are now only evaluated when they are attached to a ScriptComponent or added to StaticScripts, which means you have more control over when and how scripts are executed.

Flexible Context Policies

You now have much finer control over how script contexts (i.e., the environment a script runs in) are created. The old enable_context_sharing() has been replaced with set_context_policy() which accepts a ContextPolicy:

  • ContextPolicy::shared(): All scripts run in one global context
  • ContextPolicy::per_script(): Each script asset gets its own context (the old default.)
  • ContextPolicy::per_entity(): Each entity with scripts gets its own context.
  • ContextPolicy::per_entity_and_script(): A unique context for every script on every entity (the new default).

This means that each script is maximally isolated by default, but you can still opt for shared contexts if needed.

Other Changes

  • Recipients Enum: The Recipients enum for events has been redesigned to align with the new context policies, offering AllScripts and AllContexts variants, and removing some variants which don’t fit the new model. If you need the old behaviour, you can simply query the ECS first before sending events.
  • API Cleanup: Several types and traits were removed or simplified, including ScriptAssetSettings, AssetPathToScriptIdMapper, and ScriptMetadataStore, as they are no longer needed with the new asset-based approach.

Migration Guide

This release contains significant breaking changes. Please refer to the migration guide for detailed instructions on updating your project.

Migrating to 0.16.0

https://github.com/makspll/bevy_mod_scripting/pull/455

Replace all usages of CallbackSettings<P>.callback_handler with P::handler()(..) and P::handle(..)

https://github.com/makspll/bevy_mod_scripting/pull/456

Replace all usages of CallbackBuilder<P>.load and CallbackBuilder<P>.reload with P::load(..) and P::reload(..) or P::context_loader()(..) and P::context_reloader()(..)

https://github.com/makspll/bevy_mod_scripting/pull/463

If you were relying on BMS enabling some features in Bevy crates, your builds might be pulling in less features than you expect. Ensure you explicitly select all features you need from bevy. BMS will now only pull in strictly necessary features and crates from bevy

https://github.com/makspll/bevy_mod_scripting/pull/470

Switch all references of ContextLoadingSettings to P::readonly_config(world.id()).

https://github.com/makspll/bevy_mod_scripting/pull/471

RuntimeSettings and RuntimeContainer are removed, replace usages with P::readonly_settings(world.id()).runtime) access to initializers is no longer possible outside the plugin setup phase

https://github.com/makspll/bevy_mod_scripting/pull/472

if you implemented a scripting plugin you will need to correct your function signatures for the above aliases, and fetch the config yourself to access callbacks via Plugin::readonly_configuration(world_id) using the world id you will now receive.

https://github.com/makspll/bevy_mod_scripting/pull/473

references to StaticScripts should be replaced with appropriate resident calls on ScriptContext filtered by the attachment kind

https://github.com/makspll/bevy_mod_scripting/pull/474

  • ScriptContext Access: Use .read() and .write() to access ScriptContext (now wrapped in Arc<RwLock<>>); replace get() with get_context()
  • HandlerContext: Replace with direct ScriptContext access; remove any with_handler_system_state() calls
  • Script Callbacks: Use new call_context_dynamic() or call_context() methods from the CallContext trait
  • Custom Context Types: Implement the new GetPluginFor trait to provide mapping from context to plugin type
  • Lua Interaction: Replace mlua::Lua with LuaContext wrapper type in all Lua code on BMS side
  • Script Callback Running: Replace run_with_handler() calls with run_with_context() or run_with_contexts()

https://github.com/makspll/bevy_mod_scripting/pull/475

  • References previously resident in bevy_mod_scripting_core::asset/bevy_mod_scripting::core::asset will now need to come from bevy_mod_scripting_asset or bevy_mod_scripting::asset
  • Adding supported extensions will now need to be done via scripting_plugin.add_supported_extension("extension") rather than via the app directly
  • Plugin implementors will need to add the new crate as a dependency and should not directly rely on the top workspace crate

https://github.com/makspll/bevy_mod_scripting/pull/477

  • Update imports to new crates (bevy_mod_scripting_bindings, bevy_mod_scripting_display, bevy_mod_scripting_asset) where appropriate, if you rely on the workspace these will be re-exported under bindings, display and asset respectively
  • Replace DisplayWithWorld usage with DisplayWithTypeInfo / DebugWithTypeInfo and use WithTypeInfo::new(value) in format strings. Ensure that the WorldGuard is in scope when printing using these utilities, or you might see raw type id’s

0.16.0

Improved printing and error ergonomics

Printing has been extracted into its own bevy_mod_scripting_display crate, and brand new traits including the reflectable DisplayWithTypeInfo were written.

There are now Debug and Display equivalent traits which receive type information from semi-static thread local objects in order to print things like TypeId’s with full information.

You can now also register ReflectDisplayWithTypeInfo against your types in the reflect registry, to customize printing.

A great re-slicing

Bindings have been split out into individual crates, for example bevy_reflect has a corresponding bevy_reflect_bms_bindings crate which contain’s its bindings. This is possible thanks to a brand new tool which allows us to calculate crate dependencies across a workspace during codegen (see bevy_mod_scripting_codegen)

At the same time more bindings are now being generated after fixing some bugs in type discovery.

Other refactorings include bevy_mod_scripting_bindings, bevy_mod_scripting_display and bevy_mod_scripting_asset being pulled out into their own crates.

This has significantly improved compile times allowing us to pack more bindings!

Getting rid of HandlerCtxt

HandlerCtxt has been removed and all of its containing resources have been put in P::readonly_configuration, which is a semi-static, WorldId parameterised static.

At the same time ScriptContext<P> has been wrapped in an Arc allowing us to run callbacks within callbacks, as long as they don’t modify the same contexts!

The great bevy minification

BMS has historically pointed at the top level bevy crate, this was handy but fairly clunky as it brought way more dependencies than necessary.

From now on all BMS crates point at bevy subcrates directly, with default features disabled, this means we pull in the minimum amount of dependencies possible (in theory, as long as we didn’t miss a feature)

Brand new scripting pipeline

A shiny new overhauled loading/unloading script pipeline which:

  • Is much more customizable (want custom callbacks, or don’t like how we named our core callbacks? Just disable them and add your own!)
  • More scalable, allowing you to load thousands of scripts, without hogging your framerate (by abstracting loading into tickable state machines)

See the new docs section for details.

Pre-expanding generated code

Generated code is now expanded at generation time via cargo expand saving on compilation time for consumers.

Migrating from 0.16 to 0.17

TypedThrough Changes

PR 497

If you were relying on ladfiles or implementing TypedThrough manually, the interfaces will have changed. Some types have moved between crates.

Less types will appear in ladfiles

Changes to path reflection

PR 491

Replace accesses to tuple structs, and tuples containing underscores, i.e. instead of my_tuple._1 use my_tuple[1]

ScriptAttachment Moved to new crate

PR 490

A new crate bevy_mod_scripting_script was created, to decouple some concerns within the workspace. References will now need to use the bevy_mod_scripting::script namespace or a direct crate reference.

0.17.0 - Lua declaration files & Asset references

Lua declaration files!

On top of the ability to plug into mdbook docs, you can now generate Lua declaration files for use with the lua language server.

You can do this by simply adding the generation plugin to your app:

#![allow(unused)]
fn main() {
    // this example is used to drive the generated docs on the official BMS book
    app.add_plugins(BMSPlugin.set::<ScriptingFilesGenerationPlugin>(
        ScriptingFilesGenerationPlugin::new(
            true, // enabled, you can use a compilation feature to disable this here
            PathBuf::from("assets").join("definitions"),
            Some(PathBuf::from("bindings.lad.json")), // do also save the ladfile itself
            "Core BMS framework bindings",
            true,
            true,
        ),
    ));
}

The definitions will be generated on startup!

While the generated files are not currently perfect, and not everything is yet supported, they should already make development much smoother with basic type hints and inline docs.

Improved path reflection and dictionary/set direct access!

We have decided to drop using the native Bevy reflection paths, and switched them out with custom ReferencePath and ReferencePart structures.

This works around previous limitations of not being able to reflect and modify into dictionaries as well as reference into (but not modify sets, this one is due to limitations in the native rust type).

This should also give us some minor performance benefits.

Registered Callbacks

You can now register callbacks dynamically from your scripts like so:

function on_script_loaded()
    register_callback("on_test", dynamic_on_test)
end

function dynamic_on_test()
    register_callback("on_test_last", dynamic_on_test_last)
    return "on test: I am dynamically registered from a normal callback!"
end

This has many benefits, including allowing registering different callbacks from withing a shared global script context (where different functions are in scope depending on the last loaded script, but are predictable during loads), finally making those fully usable!

Expansion of reflection to include Asset References

The reflection system now supports a new base kind, i.e. ReflectBase::Asset

allowing us to create and send back asset references to scripts seamlessly, as well as use two new bindings (given an existing handle):

get_asset(handle_reference, registration) - Retrieves an asset by handle

has_asset(handle_reference) - Checks if an asset exists

Addition of ScriptPipelineState

A new utility has been added to allow you to check on the current batch of scripts being loaded easilly. Check it out in the new loading bar example

ScriptPath in FunctionCallContext

You can now access the last loaded script path in a script context via the FunctionCallContext::location method.

This is a lua only feature due to limitations in Rhai.

Migrating from 0.17 to 0.18

Migrate according to the official bevy migration guide. Scripts referencing native bevy bindings will also need updating accordingly.

For example in lua entity:index() will now be entity:index():index().

0.18.0 - Bevy 0.18 Support

This update only upgrades the supported version of bevy to 0.18

0.19.0

See notes for the 0.18.0 release.

Migrating from 0.19 to 0.19

Observer overhaul

TransitionListener has been deleted, use observers instead:

> app.add_observer(
>     |trigger: On<LoadingCompleted>| println!("do stuff"),
> );
< active_machines.push_listener::<ReloadingInitialized<P>>(OnLoadingCompleteListener);

This allows you to use more convenient system parameter syntax to access resources and queries, but you may not use exclusive systems anymore.

If you want observers to respect ordering between themselves, you should prefer to issue commands in these instead (see related bevy issue).

Renaming Reflection Rroxies

Val<T>, Ref<T> and Mut<T> have been renamed to prevent clashes with native bevy types, as well as save a few keystrokes.

You should use: V<T>, R<T> and M<T> instead

> V<T>
< Val<T>
> R<T>
< Ref<T>
> M<T>
< Mut<T>

ScriptValue::List changes

This variant now uses VecDeque instead of Vec

Refactor of WorldAccessGuard and related types

Many functions previously living directly in WorldAccessGuard impls, now need to be accessed via the WorldExtensions trait.

Functions previously known as with_exclusive_access etc, have been split into: with_world and with_world_mut, allowing read access to the world too in some circumstances.

ReflectAccessId was removed in favour of WorldAccessRange which can be created via Into from ComponentId’s.

0.20.0 - Ergonomics, Observer overhaul

Observer overhaul

The script loading pipeline became more idiomatic with the use of observers.

What you would do previously with TransitionListener implementations you can now do with observers registered against each machine state, for example, to react to fresh scripts being loaded you can do the following:

#![allow(unused)]
fn main() {
app.add_observer(
    |trigger: On<LoadingCompleted>| println!("do stuff"),
);
}

Callback command changes

Callback commands now accept a post_callback function pointer which can be set to execute some logic right after the callback runs, to make working with observers and callbacks easier in general.

Ironing out edge cases in the script lifecycle

Contexts are now stored in a Context enum which also contains the “state” of the context. Contexts which are being processed by the pipeline will be marked as loading/reloading or unloading, allowing us to have more information when trying to run callbakcs against these.

Callbacks which are loading or unloading for example, will not have callbacks issued to them generally.

Renaming Reflection Rroxies

Val<T>, Ref<T> and Mut<T> have been renamed to prevent clashes with native bevy types, as well as save a few keystrokes.

You should use: V<T>, R<T> and M<T> instead

Addition of logging bindings

Standard log_info, log_debug, log_trace, log_warn and log_error functions are now available in scripts by default

Variadic bindings & Support for multiple return values

The ArgMeta trait now includes: variadic() -> bool which if true, allows an argument in a binding to capture all remaining arguments from the call (effectively only usable as the last argument).

This is implemented by the brand new VariadicTuple type, which is an untyped wrapper for a variable amount of non-homogenous values.

New variants in the TypedThrough and LAD file format have ben added to represent variadics, and lua definition files generated from these will support them.

Two bindings have been added: pack_args and unpack_args to allow script code to directly create/unpack tuple variants if necessary. However for languages like Lua, supporting multiple return values, ScriptValue::Tuple variants (which is what we produce to represent variadic returns), are converted to many return values naturally.

New VecDeque impls

VecDeque now implements various BMS traits and can be used in bindings as a normal argument.

Improved domain boundaries - Extracted bevy_mod_scripting_world crate

The following types were extracted into their own crate:

  • ReflectAccessId now known as WorldAccessRange
  • ClaimOwner
  • AccessInstance
  • AccessMap
  • DynamicSystemMeta
  • WorldGuard & WorldAccessGuard

the CachedRegistry trait was introduced to store registries such as:

  • AppScriptComponentRegistry
  • AppReflectAllocator
  • AppScheduleRegistry
  • AppScriptFunctionRegistry

etc. in a type-erased way.

This allowed bevy_mod_scripting_display to directly rely on world types, and removed a lot of awkward bridging code.

More Derive Macros

The following macros derive macros are now available: ArgMeta,FromScript.

This means for types you want to clone into scripts you can make convenient wrappers like so:

#![allow(unused)]
fn main() {
#[derive(Clone, TypedThrough, GetTypeDependencies, ArgMeta, IntoScript, FromScript, Reflect)]
pub struct MyThing(usize);


#[script_bindings(remote)]
impl MyThing {
    // Can now be used directly without V<> wrapper, acts exactly like V<MyThing>
    pub fn test(thing: MyThing) -> MyThing {
        thing
    }
}
}

And overriding either the into or from implementations if you wish easilly.

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.

0.23.0 - Scripts calling scripts, constructors, namespaces

See the migration guide for breaking changes.

Scripts calling scripts

Scripts can run each other’s callbacks, in any language:

  • run_script_callback runs a callback right away and returns its result.
  • queue_script_callback runs it as soon as the current callback finishes, or in Last when called from a non-exclusive script system (ScriptingSystemSet::RunQueuedCallbacks).

Nested callbacks are now safe: re-entering a context that is already running (a script calling itself, scripts sharing a context, or a loop A → B → A) returns an error instead of freezing the app, and nesting is capped at 64. This is built on AppScriptCallbackRunners, which lets language-agnostic code run callbacks in any scripting language.

Constructors and enum variants

Every reflected type gets a new constructor, and enum variants are values:

local v = Vec3.new{ x = 1, y = 2 }            -- z is filled in from the default
local all = Recipients.AllScripts:new{}       -- construct a variant
if event.recipients:variant() == Recipients.AllScripts then ... end

Missing fields are filled in from defaults, and unknown fields are an error. The global construct follows the same rules. The generated LAD files and Lua language server definitions describe constructor payloads and variants, so editors complete and check them. In Rhai, call Type.new_.call(...), since new is reserved.

Events, messages and observers

  • world.trigger_event(type, value) and world.write_message(type, value) send reflected Bevy events and messages. trigger_event applies all pending commands, including those its observers queued, before it returns.
  • world.add_observer(event, callback, components?, entities?) runs a script callback when an event is triggered. That includes the component lifecycle events (AddEvent, InsertEvent, RemoveEvent, …), for native and script components alike. Observer callbacks never re-enter a busy script: they wait until it is free. Their errors are reported like those of other callbacks.
  • world.register_new_event(namespace, name) lets scripts define their own events, triggered with the same world.trigger_event(event, payload).

See Events and Messages.

Namespaces and modules

Types now live in namespaces: the crate that defines them, or bms for BMS’ own types. Override this with ScriptNamespace type data or #[script_bindings(namespace = "...")].

  • import_namespace("bevy_transform") returns the types in a namespace. It replaces the types global, which is now deprecated.
  • Scripts register components and events into script.* namespaces, and other scripts import them from there.
  • export_namespace(namespace, name, callback) shares a script function with other scripts, in any language.
  • A script’s exports and observers are removed when it unloads or reloads.
  • LAD files record each type’s namespace, and the Lua language server types import_namespace per namespace.

Types are indexed once in a shared, lazily rebuilt type catalogue, instead of once per script context. See Namespaces.

Script components and bundles

  • Inserting a script component no longer leaks memory.
  • register_new_component and register_new_event take an allow_existing argument, which returns the existing registration instead of failing when the name is taken (useful for scripts which run again).
  • world.insert_bundle and world.spawn_bundle insert bundles registered with #[reflect(Bundle)], all at once.

Fixes

  • on_script_reloaded always runs after on_script_loaded.
  • Fixed a rare ordering bug when iterating Vec<T> from Lua.
  • A nested callback no longer invalidates the world of the callback that called it.

Migrating from 0.23 to 0.24

Scripts

The only globals left are import_namespace, export_namespace and register_callback. Everything else, world included, is imported from a namespace, see Namespaces:

+ local world = import_namespace("bms").world
  world.spawn()

Types (Vec3, Transform, and the deprecated types table) are imported from their namespace. Bevy types are grouped by category (math, ecs, transform, ui, …), BMS’ types live in bms:

- local t = Transform.from_translation(Vec3.new(1, 2, 3))
+ local Vec3 = import_namespace("math").Vec3
+ local Transform = import_namespace("transform").Transform
+ local t = Transform.from_translation(Vec3.new(1, 2, 3))

BMS’ functions moved to bms: construct, system_builder, run_script_callback, queue_script_callback, pack_args, unpack_args and log_*. entity and script_asset are now functions:

+ local bms = import_namespace("bms")
- log_info("hi")
+ bms.log_info("hi")
- world.despawn(entity)
+ world.despawn(bms.current_entity())
- script_asset
+ bms.current_script()

Query results are plain lists of the entity followed by the components, result:entity() and result:components() are removed:

  for _, result in pairs(world.query():component(Transform):build()) do
-     local entity, transform = result:entity(), result:components()[1]
+     local entity, transform = result[1], result[2]
  end

Other changes:

  • world.get_type_by_name only takes full paths, i.e. "bevy_transform::components::transform::Transform" or "script.my_game.Enemy".
  • Numbers work on the left of operators: 2 * v, 1 - v (dispatched to mul, rsub, …), in Rhai too.

Rust

  • Script globals are removed (AppScriptGlobalsRegistry, #[script_globals], register_static*, GlobalNamespace, FunctionScope::Global, DummyScriptFunctionRegistry, use_dummy_registry, …). Put functions in a namespace instead:
    #[script_bindings(namespace = "my_game")]
    impl NamespaceMembers {
        /// `import_namespace("my_game").spawn_enemy(5)` in scripts
        fn spawn_enemy(ctxt: FunctionCallContext, hp: usize) -> Result<(), InteropError> { .. }
    }
    Values go in AppScriptNamespaceMembers::register_value, made each time the namespace is imported.
  • Types with bindings from the bevy crates are in category namespaces. Move a type with app.override_script_namespace.
  • Registering a function name twice replaces it, there are no overloads (overwrite*, iter_overloads, remove_all_overloads are removed). Take a Union or ScriptValue for arguments of different types.
  • #[derive(ScriptType)] implements everything a type needs to be used directly in function signatures (FromScript, IntoScript, ArgMeta, GetTypeDependencies, TypedThrough). Use #[script_type(from = custom)] / (into = custom) for a hand written conversion.
  • Renames: Namespace → FunctionScope, IntoNamespace → IntoFunctionScope, FromScriptRef/IntoScriptRef → FromScriptErased/IntoScriptErased, try_call_overloads → call_operator.
  • Functions on StaticTypeRef take StaticTypeRef instead of V<StaticTypeRef>.
  • ScriptFunctionRegistry is keyed by TypeId instead of FunctionScope: register(type_id, ..), get_function(type_id, name), iter_namespace → iter_type.
  • Values allocated for scripts are owned by the references to them and freed with the last one, the allocator is removed (ReflectAllocator, AppReflectAllocator, WorldExtensions::allocator, AllocatorDiagnosticPlugin, ScriptingSystemSet::GarbageCollection, InteropError::GarbageCollectedAllocation). Drop the allocator argument:
    // before
    let reference = ReflectReference::new_allocated(value, &mut world.allocator().write());
    // after
    let reference = ReflectReference::new_allocated(value);
    new_allocated_boxed and new_allocated_boxed_parial_reflect change the same way.
  • ScriptLoadingPipeline::time_budget: Option<Duration> is replaced by tick_budget: Option<usize>, the maximum amount of pipeline steps per frame, unlimited by default. ActiveMachines::budget and RunProcessingPipelineOnce::new take the same step count.
  • ScriptAttachedMessage(a) / ScriptDetachedMessage(a) are one message, ScriptLifecycleMessage::Attached(a) / ::Detached(a), so attachments and detachments are processed in the order they were written. GetScriptHandle::get_script_handle returns an Option (None: the event doesn’t wait for its script to load) and ScriptLifecycleQueue::get_ready, formerly known as LoadedWithHandles yields (event, Option<(StrongScriptHandle, Language)>).
  • An attachment whose script is still loading holds back the attachments and detachments after it, and callbacks reach scripts in a deterministic order (attachment order, until scripts are removed), see Determinism. Lua’s math.random is seeded with 0 in new contexts.
  • Script systems are identified by attachment and callback label (adding one again replaces it) and are removed with their script. ScriptSystemSet holds a recycled slot instead of the callback label, ScriptSystemBuilder no longer implements IntoSystem (use ScriptSystemBuilder::build), and their errors are sent as ScriptErrorMessages instead of being logged. WorldAccessGuard::new_non_exclusive takes an Option<Arc<ArchetypeFilter>>, restricting component accesses to the given archetypes (None for no restriction).
  • Script system parameters are declared to Bevy as they’re accessed: resource and query components as writes (they were declared as reads, or as accessing nothing for resources, while scripts could write them), resource_read / component_read as reads. Script systems writing the same resources or components no longer run in parallel. ScriptQueryBuilder::as_query_state takes a QueryAccess: Declared declares the written components as written (for queries reported to the scheduler), MatchOnly declares all components as read (i.e. for EntityRef queries only finding entities).
  • Script systems are put in and ordered against system set values (ReflectSystemSet) instead of names: scripts register sets with world.register_new_system_set(namespace, name), Rust sets are registered into a namespace with app.register_script_system_set(namespace, name, set) (ScriptSystemSetAppExt, now in bevy_mod_scripting_bindings), both are found with world.get_system_set_by_name. ScriptSystemBuilder::{in_set, before_set, after_set} take a SystemSet. ReflectSystemSet is opaque, and only its set nodes of a schedule graph have a node id.
  • ScriptQueryResult converts to a list instead of a reference, its script functions are removed.
  • ScriptQueryResult::components is a Vec<Option<ReflectReference>>, None for absent optional components. ArchetypeFilter::allow / is_allowed and WorldAccessGuard::check_archetype_access take whether the component is written.
  • AccessByteSet::from_allowed_lists(read_write, read_only) creates subsets with read only accesses. At most 63 accesses to the same value can be claimed at once, claims beyond fail (the count used to overflow).
  • WorldAccessRange::External holds the value’s owner (AccessOwner) instead of an id, and the access map keeps it alive until the claim is released. Build it from the value ((&allocation_id).into()); WorldAccessRange is no longer Copy.

Language implementations

  • Dispatch every script operation through bevy_mod_scripting_bindings::dispatch (index, set_index, static_index, binary, unary, len, iter, display, debug), see Necessary Features. WorldExtensions::lookup_function, lookup_instance_function, lookup_type_function and lookup_reserved_function are private.
  • Convert the new ScriptValue::Type(TypeId), a type itself (what world and StaticTypeRef are).
  • Set bindings::builtins::builtins() (import_namespace, export_namespace) and your register_callback as globals, nothing else. Don’t set world, entity or script_asset anymore.
  • LuaStaticReflectReference / RhaiStaticReflectReference are LuaTypeRef / RhaiTypeRef.

Documentation tooling

  • The Lua language server files are split per namespace (bindings.d.lua, bindings.<namespace>.d.lua, point workspace.library at the directory), classes are named after their namespace (math.Vec3), and generic types are declared once (Handle<Image>, needs LuaLS 3.17+).
  • cargo xtask docgen is replaced by cargo xtask docs (all binding features, --test-bindings for the script test functions). cargo xtask bless-lad updates the LAD test fixtures.
  • ThroughTypeInfo is flat (ThroughTypeInfo::Vec(..), ThroughTypeInfo::Ref(type_info)), ThroughTypeInfo::TypeInfo is Opaque. #[derive(TypedThrough)] documents a type as opaque, #[typed_through(value)] as a value.
  • LAD: LadFieldOrVariableKind → LadTypeKind; globals is removed, builtin functions are LadFunctionNamespace::Global (the mdbook “Globals” and “Functions” pages are one “Builtins” page), namespaces have values (add_instance* → add_namespace_value_of / add_namespace_instance); new namespaces, generic_types, LadTypeDefinition::generic_type, LadFunction::receiver, LadFunctionMetadata::operator (replaces is_operator); arguments are always named and never include the call context; polymorphizied_types is removed. ArgumentVisitor has an Output type and visit_* methods.

Scripting Reference

This part of the book covers the user-facing API of the scripting languages supported by BMS. This will be where you will want to forward your script users to get started with scripting in BMS.

If you are a modder, welcome! 👋, apologies for the rust-centricity of this guide, we are working on it!

Globals

Scripts have only a few builtin globals:

  • import_namespace(namespace): returns the types and functions of a namespace
  • export_namespace(namespace, name, callback): see Exporting functions
  • register_callback(label, function): registers a function as a callback handler

Everything else is imported. world is a static reference to the world, with all sorts of functions available: import_namespace("bms").world. BMS’ own functions are in bms, i.e. bms.current_entity() (the entity the script is attached to, or nil) and bms.current_script() (the script’s handle):

local bms = import_namespace("bms")
print(bms.current_entity())

Constructing Arbitrary Types

When interfacing with bevy, we do this via reflection. While the bevy bindings do not cover constructors for every single type that bevy or other libraries provide, reflection allows us to construct some (not all types implement FromReflect) types from dynamic structs.

BMS exposes this ability to all script writers via the new function available on every type, as well as the more verbose bms.construct.

Type.new

Every type has a new function, taking a table of the fields to set. Types are reached through their namespace, i.e. import_namespace("my_game").MyStruct:

pub struct MyStruct {
    pub my_field: String,
    pub other_field: usize,
}
local MyStruct = import_namespace("my_game").MyStruct
local my_struct = MyStruct.new({
    my_field = "hello",
    other_field = 5,
})
pub struct MyTupleStruct(pub String);

Tuple structs and tuples are constructed using the index of the field as the key, the keys follow the indexing convention of the language, i.e. in Lua the first field is "1":

local my_tuple_struct = MyTupleStruct.new({
    ["1"] = "hello",
})

A list is taken to be the fields in order, which is usually the more natural way to write tuple structs:

local my_tuple_struct = MyTupleStruct.new({ "hello" })

Types which are not structs, tuple structs, tuples or enums, can be constructed only if they implement Default, using Type.new({}).

Defaults

Fields which are not provided are filled in, in the following order of priority:

  1. the value from the type’s Default implementation, if it has one. For enums, only if the default is the variant being constructed
  2. the Default of the field’s type, if it has one

If neither is available the construction fails, and the error names the missing field. Entries which are not fields of the type, i.e. a misspelled field name, are an error too, rather than being ignored in favour of a default. The generated Lua language server files mark exactly these fields as optional, see Editor support.

Naming and priority

new is a single function shared by all types, and is made available on every type. A function with the same name registered on the type itself always takes priority, i.e. Vec3.new(x, y, z) is the Vec3 constructor from the math bindings, not the shared one. For such types use bms.construct, which works for every type.

The name of the function is configurable via the ConstructorsPlugin:

app.add_plugins(BMSPlugin.set(ConstructorsPlugin {
    constructor_name: "create".into(),
}));

The function is registered under the StaticTypeRef type, which is where functions available on all types are registered.

Enums

The following enum:

pub enum MyEnum {
    VariantA {
        field: String
    },
    VariantB(usize),
    VariantC,
}

has its variants available as MyEnum.VariantA, MyEnum.VariantB and MyEnum.VariantC, which can be used to construct values of the variant using :new:

local a = MyEnum.VariantA:new({ field = "hello" })
local b = MyEnum.VariantB:new({ 5 })
local c = MyEnum.VariantC:new({})

The enum’s Default only fills in fields if it is the variant being constructed.

You can also pick the variant by name using MyEnum.new({ variant = "VariantA", field = "hello" }).

Discriminating variants

The variant a value is in can be obtained with :variant(), and compared with the variants of the enum:

if my_enum:variant() == MyEnum.VariantA then
    print(my_enum.field)
end

This is also useful with enums that carry no data, such as keys:

local KeyCode = import_namespace("input").KeyCode
if event.key_code:variant() == KeyCode.KeyA then
    print("A was pressed")
end

:variant() returns nil if the value is not an enum. If you need the name of the variant, :variant_name() is also available on both values and variants.

Variants named like functions

Functions on the type take priority over variants, so a variant named like a function cannot be accessed with MyEnum.Name. Use world.get_enum_variant to get at it in that case:

local world = import_namespace("bms").world
local variant = world.get_enum_variant(import_namespace("my_game").MyEnum, "Name")

bms.construct

The bms.construct function constructs types from a registration. It works for every type, including those whose own new function shadows the shared one, and is useful if you only have the type as a value:

local bms = import_namespace("bms")
local my_game = import_namespace("my_game") -- the crate defining the types
local concrete_my_struct = bms.construct(my_game.MyStruct, {
    my_field = "hello"
})

local variantA = bms.construct(my_game.MyEnum, {
    variant = "VariantA",
    field = "hello"
})

local vec = bms.construct(import_namespace("math").Vec3, { x = 1, y = 2, z = 3 })

Missing fields are filled in from defaults in the same way as for new.

Editor support

The Lua language server files describe the table each constructor takes, so editors can complete and check the fields. A field is optional exactly when a default can fill it in, as described in Defaults:

#[derive(Reflect)]
pub struct MyStruct {
    pub my_field: String,
    pub handle: MyHandle, // no `Default`
}
---@class (exact) MyStruct.Fields
---@field my_field? string
---@field handle MyHandle
---@field [any] 'never'

---@param payload MyStruct.Fields
---@return MyStruct
function MyStruct.new(payload) end

The language server then warns about missing required fields, fields of the wrong type, and unknown fields, i.e. a misspelled my_feild. The last line rejects unknown fields: until the language server checks exact classes against tables passed to functions (LuaLS/lua-language-server#1990), any undeclared field has to be of a type no value has, so the warning reads “Cannot assign string to 'never'”.

Tuple fields are declared under their integer keys, i.e. [1], which a list such as { "hello" } fills in, so prefer lists for tuple structs. Types and variants without fields all take NoFields, i.e. {}.

Each enum variant has a class of its own, i.e. MyEnum.VariantA, so MyEnum.VariantA:new{ completes the fields of VariantA and returns a MyEnum.

The table of MyEnum.new{ variant = "VariantA", ... } is not described, as the language server cannot narrow its fields down by the variant given. Prefer MyEnum.VariantA:new{...}, which is checked.

Since the type of bms.construct’s first argument is only known when the script runs, its table is not described.

Events and Messages

Scripts can send Bevy events (observer-style, run immediately) and messages (buffered, read later by MessageReaders) using the reflection data Bevy generates for them.

FunctionRust type data requiredBehaviour
world.trigger_event(type, value)ReflectEventTriggers the event. Observers run, and all pending commands are applied, before the call returns. Also triggers script events.
world.write_message(type, value)ReflectMessageWrites the message to its Messages<T> buffer, readers see it later in the frame.
local world = import_namespace("bms").world
local my_game = import_namespace("my_game") -- the crate defining the types
world.trigger_event(my_game.MyEvent, my_game.MyEvent.new({ amount = 3 }))
world.write_message(my_game.MyMessage, my_game.MyMessage.new({ amount = 3 }))

The value is copied when sent, so the same value can be sent again, and changing it afterwards does not affect events already sent.

Registration requirements

Only types which are registered with the matching reflect attribute can be sent, anything else errors with a missing type data error:

#[derive(Event, Reflect)]
#[reflect(Event)]
struct MyEvent { amount: usize }

#[derive(Message, Reflect)]
#[reflect(Message)]
struct MyMessage { amount: usize }

app.register_type::<MyEvent>()
   .register_type::<MyMessage>()
   // messages must also be added as usual, otherwise there is nothing to write them to
   .add_message::<MyMessage>();
  • The type must be registered with register_type, otherwise scripts cannot import it.
  • #[reflect(Event)] is only generated for events using the default (global) trigger. Events with custom triggers, such as entity events, need a hand-written ReflectEvent.
  • Types which do not implement FromReflect (all fields must be reflectable) cannot be sent.
  • Bevy’s own events and messages are not usable unless they have the reflect attributes.

Things to be aware of

  • trigger_event needs exclusive access to the world, so it fails with an access error if the script is currently holding a borrowed reference elsewhere in the same call (e.g. inside a query iteration or with_* access). Trigger events from regular callbacks.
  • Observers run before trigger_event returns, and so do the commands they queue (as for other operations such as spawning). A Rust observer or command which runs a callback in the currently executing script context fails with an error. Use bms.run_script_callback or bms.queue_script_callback instead (see Calling Other Scripts).

Observing events from scripts

world.add_observer(event, callback, components?, entities?) runs the calling script’s callback callback (registered with register_callback, or a top level function of that name) with a copy of the event, whenever the event is triggered. It returns the observer entity: despawn it to remove the observer.

local world = import_namespace("bms").world
local ecs = import_namespace("ecs")
local Mana = world.register_new_component("script.my_game", "Mana")

register_callback("on_mana_added", function(event)
    print("Mana was added to", event.entity)
end)

local observer = world.add_observer(ecs.AddEvent, "on_mana_added", { Mana })
world.despawn(observer) -- later
  • The lifecycle events AddEvent, InsertEvent, DiscardEvent, RemoveEvent and DespawnEvent (in ecs) work for any native or script component. Other events need #[reflect(Event)].
  • As in Bevy, components is an OR filter, and entities restricts the observer to those entities.
  • Callbacks run right after the triggering operation, in unspecified order. If the script’s context is busy (e.g. it triggered the event), the callback runs as soon as the busy callback finishes, so observers never re-enter a running script.
  • The world is already past the change: removed component data can’t be read in RemoveEvent callbacks.
  • Errors are reported like those of other callbacks (ScriptErrorMessage), and don’t fail the triggering operation.
  • add_observer only works inside a script callback.

Script defined events

Scripts can define events carrying any value:

local world = import_namespace("bms").world
local Damaged = world.register_new_event("script.my_game", "Damaged")

register_callback("on_damaged", function(payload)
    print("took damage:", payload.amount)
end)

world.add_observer(Damaged, "on_damaged")
world.trigger_event(Damaged, { amount = 5 })
  • register_new_event fails if the name is taken, unless allow_existing (third argument) is passed.
  • Script events are global: components and entities are ignored.
  • Other scripts get them with import_namespace, i.e. import_namespace("script.my_game").Damaged.

Built-in messages

The following BMS messages are reflected and can be written from scripts:

  • ScriptCallbackMessage: runs a callback on other scripts, processed later in the frame by the handler systems set up for its callback label. Labels without a handler system are never processed, prefer bms.queue_script_callback to run callbacks from scripts.
  • ScriptLifecycleMessage (Attached / Detached), ScriptAssetModifiedMessage: drive the script loading pipeline

The internal loading pipeline state events (LoadingCompleted, ContextAssigned, …) are intentionally not reflected.

Bundles

Scripts can insert bundles defined in Rust, all components at once:

FunctionBehaviour
world.insert_bundle(entity, type, value)Inserts the bundle’s components into the entity.
world.spawn_bundle(type, value)Spawns an entity with the bundle and returns it.

Bundles need ReflectBundle type data, and are constructed like any other type:

#[derive(Bundle, Reflect, Default)]
#[reflect(Bundle, Default)]
struct EnemyBundle {
    health: Health,
    transform: Transform,
}

app.register_type::<EnemyBundle>();
// tuples and foreign bundles: app.register_type_data::<(Health, Transform), ReflectBundle>()
local world = import_namespace("bms").world
local EnemyBundle = import_namespace("my_game").EnemyBundle
world.spawn_bundle(EnemyBundle, EnemyBundle.new({ health = Health.new({ hp = 10 }) }))

Namespaces

Every type known to scripts lives in a namespace, and scripts reach types through their namespace: there are no globals named after types.

TypesNamespace
bevy types covered by the bevy bindings, grouped by categorymath, ecs, time, transform, color, input, window, asset, camera, render, sprite, text, ui, gizmos, animation, audio, state
BMS’ own types (ScriptAttachment, ReflectReference, …)bms
any other typethe name of the crate defining it, i.e. my_game
primitives like i32the root namespace, ""

A category namespace holds every type of the bevy crates it covers, i.e. math holds the types of glam and bevy_math, render those of bevy_render, bevy_pbr, bevy_light, bevy_mesh and bevy_image.

Type:namespace() returns a type’s namespace. Script registered components and events live in script.* namespaces, see below.

Importing a namespace

import_namespace(namespace) returns a table of the namespace’s types (and, for script namespaces, events and exported functions) by short name. Each type can be used to call its static functions, to access its enum variants, and wherever a type is expected:

local bms = import_namespace("bms")
local world = bms.world
local Vec3 = import_namespace("math").Vec3
local transform = import_namespace("transform")

local t = transform.Transform.from_translation(Vec3.new(0, 1, 0))
world.add_default_component(bms.current_entity(), transform.Transform)

Import once at the top of a script, and keep the types you use in locals. In Lua, don’t name the table of the math namespace math: that would hide Lua’s own math library.

  • If two types in a namespace share a short name, the first one registered wins.
  • Each call reads the shared type catalogue, so the result is always up to date. A table imported earlier does not pick up later registrations: import again.
  • A namespace which does not exist is an error, with suggestions: namespace "transfrom" does not exist. ... Did you mean: transform?
  • To also expose every type as a global named after it (i.e. Vec3), as before 0.24, set CoreScriptGlobalsPlugin::register_static_references. Types sharing a name then shadow each other.

Overriding the namespace of a type

// on types with script bindings: keeps a namespace set before (with a warning)
#[script_bindings(namespace = "my_namespace")]
impl MyType { /* ... */ }

// on any type: always wins, before or after `script_bindings`
app.override_script_namespace::<MyType>("my_namespace"); // bevy_mod_scripting::bindings::ScriptNamespaceAppExt
// or directly
registry.register_type_data_with::<MyType, ScriptNamespace, _>("my_namespace");

Namespaces defined by scripts

Scripts register components and events into namespaces they pass explicitly. These start with script., followed by dot-separated segments of letters, digits and underscores:

local bms = import_namespace("bms")
local world = bms.world
local Enemy = world.register_new_component("script.game.ai", "Enemy")
local Hit = world.register_new_event("script.game.ai", "Hit")

-- anywhere, including other scripts
local ai = import_namespace("script.game.ai")
world.add_default_component(bms.current_entity(), ai.Enemy)
world.trigger_event(ai.Hit, { damage = 3 })
  • Names are unique within a namespace, across components, events and exports: script.game.ai.Enemy and script.game.ui.Enemy are different components.
  • Registering a taken name is an error. allow_existing returns the existing registration instead, which is useful for scripts which run again.
  • A script namespace exists once something is registered or exported into it.
  • Components and events stay registered when their script unloads, as Bevy cannot unregister components.

Values of script components are DynamicComponents, holding any value in data. Tables read from data are copies: assign a new table to change them.

local bms = import_namespace("bms")
local world = bms.world
local DynamicComponent = bms.DynamicComponent
world.insert_component(bms.current_entity(), Enemy, DynamicComponent.new({ data = { hp = 5 } }))
local enemy = world.get_component(bms.current_entity(), Enemy)
enemy.data = { hp = enemy.data.hp - 1 } -- `enemy.data.hp = 4` would not write through

Exporting functions

export_namespace(namespace, name, callback) makes a callback of the calling script callable by other scripts, in any language:

-- script A
local world = import_namespace("bms").world
register_callback("spawn_enemy_impl", function(health)
    return world.spawn()
end)
export_namespace("script.game", "spawn_enemy", "spawn_enemy_impl")

-- script B, once script A has run
local enemy = import_namespace("script.game").spawn_enemy(5)
  • callback is a function registered with register_callback, or a top level function of that name. Only functions can be exported.
  • Calls run in the exporting script’s context, like bms.run_script_callback (see Calling Other Scripts), and return the callback’s result.
  • A script cannot call its own exports, or those of scripts sharing its context, from one of its callbacks: its context is busy. Call the function directly instead.
  • Exports are looked up on every call, so replaced exports are picked up and removed ones fail with an error.
  • A path can only be exported by one script. Exporting it again from the same script replaces it. Exports can’t share a path with a component.
  • export_namespace only works inside a script callback.

When a script unloads or is about to reload, its exports and observers are removed right after its on_script_unloaded callback. Export from a callback which runs on load (e.g. on_script_loaded), so a reloaded script exports again.

Editor support

LAD files record each type’s namespace. The Lua language server definitions declare a namespace.<name> class per native namespace, and import_namespace("transform") returns the matching class, so completion works on imported tables. Script namespaces only exist at runtime and are untyped.

Calling Other Scripts

Scripts can run callbacks of other scripts, in any scripting language, using two functions:

FunctionWhen the callback runsReturns
bms.run_script_callback(label, target, ...args)Immediately, before the call returnsWhat the callback returned
bms.queue_script_callback(label, target, ...args)As soon as the current callback finishes, in the same frameNothing
local bms = import_namespace("bms")
local ScriptAttachment, Recipients = bms.ScriptAttachment, bms.Recipients
local enemy_script = ScriptAttachment.new_entity_script(enemy, bms.current_script())

-- runs `take_damage(10, "fire")` in the enemy's script right away
local remaining_health = bms.run_script_callback("take_damage", enemy_script, 10, "fire")

-- runs `on_hit()` in every script once this callback is done
bms.queue_script_callback("on_hit", Recipients.all_scripts())
let bms = import_namespace("bms");
let ScriptAttachment = bms.ScriptAttachment;
let Recipients = bms.Recipients;
let enemy_script = ScriptAttachment.new_entity_script(enemy, bms.current_script());

// runs `take_damage(10, "fire")` in the enemy's script right away
let remaining_health = bms.run_script_callback("take_damage", enemy_script, 10, "fire");

// runs `on_hit()` in every script once this callback is done
bms.queue_script_callback("on_hit", Recipients.all_scripts());

Targets

The target is either a single script:

  • ScriptAttachment.new_static_script(script)
  • ScriptAttachment.new_entity_script(entity, script)

or a set of Recipients:

  • Recipients.all_scripts(): every loaded script, once per script even if scripts share a context
  • Recipients.all_contexts(): every loaded context once
  • Recipients.static_script(script)
  • Recipients.entity_script(entity, script)

For a single script, bms.run_script_callback returns the callback’s value. For recipients it returns a list with the value of each script which ran the callback. Scripts which are still loading or unloading are skipped when targeting many scripts, while targeting a specific script which is not loaded is an error.

Errors

  • bms.run_script_callback raises the callback’s error in the calling script, so it can be handled like any other error. For recipients, the first error is raised after all scripts ran the callback.
  • Errors of queued callbacks cannot reach the script which queued them, they are reported like other script errors (logged by default).

Which scripts can be called immediately

While a callback runs, its script context is busy, so bms.run_script_callback cannot run a callback in a busy context. This includes:

  • the calling script itself (call the function directly instead),
  • scripts sharing a context with the calling script,
  • scripts further up the current chain of callbacks, e.g. A calls B, which calls A again.

These calls return an error instead. bms.queue_script_callback works for all of them, since queued callbacks only run once the current callback has finished.

Whether scripts share a context depends on the context policy of the scripting plugin:

Context policyScripts sharing a context
ContextPolicy::per_entity_and_script() (default)None
ContextPolicy::per_entity()All scripts attached to the same entity
ContextPolicy::per_script()All attachments of the same script
ContextPolicy::shared()All scripts

Queued callbacks

  • Queued callbacks run in the order they were queued, and can queue further callbacks, which run in the same go.
  • They never run in the middle of the callback which queued them, even if it keeps using the world afterwards.
  • To stop callbacks from queueing each other endlessly, at most 1024 queued callbacks run in one go. Any beyond that run later, and an error is reported.

Script systems

Script systems running in parallel with other systems (i.e. not marked exclusive) cannot use bms.run_script_callback, as another system might be running the target script at the same time. Callbacks they queue run at the end of the frame instead, in the ScriptingSystemSet::RunQueuedCallbacks system set in the Last schedule.

Limits

  • Callbacks can be nested at most 64 levels deep, i.e. a callback running another callback which runs another one and so on.

Core Bindings

Contents

This is an automatically generated file, you’ll find links to the contents below

Builtins

The only globals of scripts. Everything else is imported from a namespace, see the namespace pages under Types, i.e. import_namespace("bms").world.

For function details and documentation, click on the function link.

FunctionSummary
export_namespaceExports a callback of the calling script as a function in a script namespace, so that any script (in...
import_namespaceImports a namespace, returning a table of the types, functions, values, events, system sets and expo...
register_callbackRegisters a function as the handler of a callback, taking precedence over a top level function of th...

export_namespace

Exports a callback of the calling script as a function in a script namespace, so that any script (in any language) can call it.

The callback is either a function registered with register_callback, or a top level function with that name. Calls run in the exporting script and return what the callback returns.

register_callback("spawn_enemy_impl", function(health) ... end)
export_namespace("script.game", "spawn_enemy", "spawn_enemy_impl")
-- in another script, once the first one has run
import_namespace("script.game").spawn_enemy(5)

Arguments

NameTypeDocumentation
nameStringthe name of the function within the namespace.
callbackStringthe label of the callback of this script to export.
arg3StringNo Documentation 🚧

Returns

NameTypeDocumentation
result()Nothing if the function was exported.

import_namespace

Imports a namespace, returning a table of the types, functions, values, events, system sets and exports in it by name.

Bevy types with bindings live in a namespace per category (math, ecs, transform, ui, …), BMS’ own types and functions in bms, any other type in the namespace named after the crate defining it. Namespaces defined by scripts start with script..

local bms = import_namespace("bms")
local Vec3 = import_namespace("math").Vec3
bms.world.spawn()

Fails with a list of similar namespaces if the namespace does not exist.

Arguments

NameTypeDocumentation
arg1StringNo Documentation 🚧

Returns

NameTypeDocumentation
namespaceScriptValuea table of the contents of the namespace keyed by name.

register_callback

Registers a function as the handler of a callback, taking precedence over a top level function of that name.

register_callback("on_script_unloaded", function() print("unloading!") end)

Arguments

NameTypeDocumentation
callbackStringthe callback label to register the function against.
functionDynamicFunctionthe function handling the callback.

Returns

NameTypeDocumentation
return()No Documentation 🚧

Types

Namespaces

Types are grouped by the namespace scripts import them from, i.e. import_namespace("math").

alloc

The types and functions in the alloc namespace, as returned by import_namespace("alloc").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
CowNo Documentation 🚧

Cow

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Cow>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCowThe constructed value.

animation

The types and functions in the animation namespace, as returned by import_namespace("animation").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
AnimationPlayerAnimation controls. Automatically added to any root animations of a scene when it is spawned.
AnimationGraphA graph structure that describes how animation clips are to be blended together. Applications fr...
NodeIndexNo Documentation 🚧
ActiveAnimationAn animation that an [`AnimationPlayer`] is currently either playing or was playing, but is presently paused. A stopped animation is considered no longer active.
AnimationTargetIdA component that identifies which parts of an [`AnimationClip`] asset can be applied to an entity. Typically used alongside the [`AnimatedBy`]...
RepeatAnimationRepetition behavior of an animation.

AnimationPlayer

AnimationPlayer

Description

Animation controls.

Automatically added to any root animations of a scene when it is spawned.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
seek_toJumps the animation `node` to `seconds` into its clip. Errors if it is not playing.
all_pausedWhether every playing animation is paused. True when nothing is playing.
pause_allPauses all playing animations.
resume_allResumes all paused animations.
is_playing_animationWhether the animation `node` is playing or paused.
stopStops the animation `node` and removes it from the player.
all_finishedWhether every playing animation has finished. True when nothing is playing.
set_repeat_foreverMakes the animation `node` repeat forever. Errors if it is not playing.
animation_is_finishedWhether the animation `node` has finished, or nil if it is not playing.
playStarts playing the animation `node`. Does nothing if it is already playing.
set_speedSets the playback speed of the animation `node`, where `1.0` is normal speed. Errors if it is not pl...
stop_allStops all animations and removes them from the player.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

seek_to

Jumps the animation node to seconds into its clip. Errors if it is not playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧
secondsF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

all_paused

Whether every playing animation is paused. True when nothing is playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pause_all

Pauses all playing animations.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

resume_all

Resumes all paused animations.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

is_playing_animation

Whether the animation node is playing or paused.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

stop

Stops the animation node and removes it from the player.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

all_finished

Whether every playing animation has finished. True when nothing is playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

set_repeat_forever

Makes the animation node repeat forever. Errors if it is not playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

animation_is_finished

Whether the animation node has finished, or nil if it is not playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Bool>No Documentation 🚧

play

Starts playing the animation node. Does nothing if it is already playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

set_speed

Sets the playback speed of the animation node, where 1.0 is normal speed. Errors if it is not playing.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧
nodeNodeIndexNo Documentation 🚧
speedF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

stop_all

Stops all animations and removes them from the player.

Arguments

NameTypeDocumentation
_selfAnimationPlayerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AnimationPlayer>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAnimationPlayerThe constructed value.

AnimationGraph

AnimationGraph

Description

A graph structure that describes how animation clips are to be blended together.

Applications frequently want to be able to play multiple animations at once and to fine-tune the influence that animations have on a skinned mesh. Bevy uses an animation graph to store this information. Animation graphs are a directed acyclic graph (DAG) that describes how animations are to be weighted and combined together. Every frame, Bevy evaluates the graph from the root and blends the animations together in a bottom-up fashion to produce the final pose.

There are three types of nodes: blend nodes, add nodes, and clip nodes, all of which can have an associated weight. Blend nodes and add nodes have no associated animation clip and combine the animations of their children according to those children’s weights. Clip nodes specify an animation clip to play. When a graph is created, it starts with only a single blend node, the root node.

For example, consider the following graph:

┌────────────┐                                      
│            │                                      
│    Idle    ├─────────────────────┐                
│            │                     │                
└────────────┘                     │                
                                   │                
┌────────────┐                     │  ┌────────────┐
│            │                     │  │            │
│    Run     ├──┐                  ├──┤    Root    │
│            │  │  ┌────────────┐  │  │            │
└────────────┘  │  │   Blend    │  │  └────────────┘
                ├──┤            ├──┘                
┌────────────┐  │  │    0.5     │                   
│            │  │  └────────────┘                   
│    Walk    ├──┘                                   
│            │                                      
└────────────┘                                      

In this case, assuming that Idle, Run, and Walk are all playing with weight 1.0, the Run and Walk animations will be equally blended together, then their weights will be halved and finally blended with the Idle animation. Thus the weight of Run and Walk are effectively half of the weight of Idle.

Nodes can optionally have a mask, a bitfield that restricts the set of animation targets that the node and its descendants affect. Each bit in the mask corresponds to a mask group, which is a set of animation targets (bones). An animation target can belong to any number of mask groups within the context of an animation graph.

When the appropriate bit is set in a node’s mask, neither the node nor its descendants will animate any animation targets belonging to that mask group. That is, setting a mask bit to 1 disables the animation targets in that group. If an animation target belongs to multiple mask groups, masking any one of the mask groups that it belongs to will mask that animation target. (Thus an animation target will only be animated if all of its mask groups are unmasked.)

A common use of masks is to allow characters to hold objects. For this, the typical workflow is to assign each character’s hand to a mask group. Then, when the character picks up an object, the application masks out the hand that the object is held in for the character’s animation set, then positions the hand’s digits as necessary to grasp the object. The character’s animations will continue to play but will not affect the hand, which will continue to be depicted as holding the object.

Animation graphs are assets and can be serialized to and loaded from RON files. Canonically, such files have an .animgraph.ron extension.

The animation graph implements RFC 51. See that document for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_clipAdds the clip `handle` under the node `parent`, with `weight` relative to its siblings. Returns the ...
from_clipA new graph that plays `handle` on its own at full weight.
root_nodeThe index of the root node of the graph, which all of its animations are blended into.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_clip

Adds the clip handle under the node parent, with weight relative to its siblings. Returns the new node.

Arguments

NameTypeDocumentation
_selfAnimationGraphNo Documentation 🚧
handlebevy_asset::handle::Handle<bevy_animation::AnimationClip>No Documentation 🚧
weightF32No Documentation 🚧
parentNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
returnNodeIndexNo Documentation 🚧

from_clip

A new graph that plays handle on its own at full weight.

Arguments

NameTypeDocumentation
handlebevy_asset::handle::Handle<bevy_animation::AnimationClip>No Documentation 🚧

Returns

NameTypeDocumentation
returnAnimationGraphNo Documentation 🚧

root_node

The index of the root node of the graph, which all of its animations are blended into.

Arguments

NameTypeDocumentation
_selfAnimationGraphNo Documentation 🚧

Returns

NameTypeDocumentation
returnNodeIndexNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AnimationGraph>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAnimationGraphThe constructed value.

NodeIndex

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
indexThe number of this node index.
newA node index from its number. Scripts see this type as `NodeIndex`. ```multi-lang-example,lua local NodeIndex = import_namespace(“animation”).NodeIndex local node = NodeIndex.new(3) assert(node:index() == 3) ``` ```multi-lang-example,rune let NodeIndex = import_...

index

The number of this node index.

Arguments

NameTypeDocumentation
_selfNodeIndexNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

new

A node index from its number.

Scripts see this type as NodeIndex.

local NodeIndex = import_namespace("animation").NodeIndex
local node = NodeIndex.new(3)
assert(node:index() == 3)
let NodeIndex = import_namespace("animation").NodeIndex;
let node = NodeIndex.new(3);
assert!(node.index() == 3);

Arguments

NameTypeDocumentation
indexU32No Documentation 🚧

Returns

NameTypeDocumentation
returnNodeIndexNo Documentation 🚧

ActiveAnimation

ActiveAnimation

Description

An animation that an [AnimationPlayer] is currently either playing or was playing, but is presently paused.

A stopped animation is considered no longer active.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ActiveAnimation>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceActiveAnimationThe constructed value.

AnimationTargetId

AnimationTargetId

  1. Uuid

Description

A component that identifies which parts of an [AnimationClip] asset can be applied to an entity. Typically used alongside the [AnimatedBy] component.

AnimationTargetId is implemented as a UUID. When importing an armature or an animation clip, asset loaders typically use the full path name from the armature to the bone to generate these UUIDs. The ID is unique to the full path name and based only on the names. So, for example, any imported armature with a bone at the root named Hips will assign the same [AnimationTargetId] to its root bone. Likewise, any imported animation clip that animates a root bone named Hips will reference the same [AnimationTargetId]. Any animation is playable on any armature as long as the bone names match, which allows for easy animation retargeting.

Note that asset loaders generally use the full path name to generate the [AnimationTargetId]. Thus a bone named Chest directly connected to a bone named Hips will have a different ID from a bone named Chest that’s connected to a bone named Stomach.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AnimationTargetId>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAnimationTargetIdThe constructed value.

RepeatAnimation

Never

Count

  1. U32

Forever

Description

Repetition behavior of an animation.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Count.newNo Documentation 🚧
Forever.newNo Documentation 🚧
Never.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RepeatAnimation>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRepeatAnimationThe constructed value.

Count.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RepeatAnimation::Count>No Documentation 🚧

Returns

NameTypeDocumentation
returnRepeatAnimationNo Documentation 🚧

Forever.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RepeatAnimation::Forever>No Documentation 🚧

Returns

NameTypeDocumentation
returnRepeatAnimationNo Documentation 🚧

Never.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RepeatAnimation::Never>No Documentation 🚧

Returns

NameTypeDocumentation
returnRepeatAnimationNo Documentation 🚧

asset

The types and functions in the asset namespace, as returned by import_namespace("asset").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
AssetIndexA generational runtime-only identifier for a specific [`Asset`] stored in [`Assets`]. This is optim...
AssetPathRepresents a path to an asset in a “virtual filesystem”. Asset paths consist of three main parts:...
RenderAssetUsagesDefines where the asset will be used. If an asset is set to the `RENDER_WORLD` but not the `MAIN_WORLD`...
ArcMutexValue<Image>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<TextureAtlasLayout>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<Mesh>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<ScriptAsset>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<ShaderBuffer>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<ColorMaterial>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
ArcMutexValue<SpriteMeshMaterial>Stores an [`Arc<Mutex<AssetOrHandle>>`]. This intermediary type exists largely to enable reflect(opaque).
HandleTemplate<Image>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<TextureAtlasLayout>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<Mesh>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<ScriptAsset>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<ShaderBuffer>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<ColorMaterial>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
HandleTemplate<SpriteMeshMaterial>A [`Template`] that produces a [`Handle`]. # How asset paths are resolved in templates When a t...
AssetId<ScriptAsset>A unique runtime-only identifier for an [`Asset`]. This is cheap to [`Copy`]/[`Clone`] and is not directly tied to the lifetime of the Asset. This means it _can_ point to an [`Asset`]...
Handle<A>A handle to an asset of type `A`.

Values

NameType
AssetEventSystemsReflectSystemSet
AssetTrackingSystemsReflectSystemSet

AssetIndex

AssetIndex

Description

A generational runtime-only identifier for a specific [Asset] stored in [Assets]. This is optimized for efficient runtime usage and is not suitable for identifying assets across app runs.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AssetIndex>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAssetIndexThe constructed value.

AssetPath

Opaque Type. 🔒

Description

Represents a path to an asset in a “virtual filesystem”.

Asset paths consist of three main parts:

  • [AssetPath::source]: The name of the AssetSource to load the asset from. This is optional. If one is not set the default source will be used (which is the assets folder by default).
  • [AssetPath::path]: The “virtual filesystem path” pointing to an asset source file.
  • [AssetPath::label]: An optional “named sub asset”. When assets are loaded, they are allowed to load “sub assets” of any type, which are identified by a named “label”.

Asset paths are generally constructed (and visualized) as strings:

# use bevy_asset::{Asset, AssetServer, Handle};
# use bevy_reflect::TypePath;
#
# #[derive(Asset, TypePath, Default)]
# struct Mesh;
#
# #[derive(Asset, TypePath, Default)]
# struct Scene;
#
# let asset_server: AssetServer = panic!();
// This loads the `my_scene.scn` base asset from the default asset source.
let scene: Handle<Scene> = asset_server.load("my_scene.scn");

// This loads the `PlayerMesh` labeled asset from the `my_scene.scn` base asset in the default asset source.
let mesh: Handle<Mesh> = asset_server.load("my_scene.scn#PlayerMesh");

// This loads the `my_scene.scn` base asset from a custom 'remote' asset source.
let scene: Handle<Scene> = asset_server.load("remote://my_scene.scn");

[AssetPath] implements [From] for &'static str, &'static Path, and &'a String, which allows us to optimize the static cases. This means that the common case of asset_server.load("my_scene.scn") when it creates and clones internal owned AssetPaths. This also means that you should use [AssetPath::parse] in cases where &str is the explicit type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AssetPath>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAssetPathThe constructed value.

RenderAssetUsages

Opaque Type. 🔒

Description

Defines where the asset will be used.

If an asset is set to the RENDER_WORLD but not the MAIN_WORLD, the asset data (pixel data, mesh vertex data, etc) will be removed from the cpu-side asset once it’s been extracted and prepared in the render world. The asset will remain in the assets collection, but with only metadata.

Unloading the asset data saves on memory, as for most cases it is no longer necessary to keep it in RAM once it’s been uploaded to the GPU’s VRAM. However, this means you cannot access the asset data from the CPU (via the Assets<T> resource) once unloaded (without re-loading it).

If you never need access to the asset from the CPU past the first frame it’s loaded on, or only need very infrequent access, then set this to RENDER_WORLD. Otherwise, set this to RENDER_WORLD | MAIN_WORLD.

If you have an asset that doesn’t actually need to end up in the render world, like an Image that will be decoded into another Image asset, use MAIN_WORLD only.

Platform-specific

On Wasm, it is not possible for now to free reserved memory. To control memory usage, load assets in sequence and unload one before loading the next. See this discussion about memory management for more details.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RenderAssetUsages>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRenderAssetUsagesThe constructed value.

ArcMutexValue<Image>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<Image>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<Image>The constructed value.

ArcMutexValue<TextureAtlasLayout>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<TextureAtlasLayout>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<TextureAtlasLayout>The constructed value.

ArcMutexValue<Mesh>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<Mesh>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<Mesh>The constructed value.

ArcMutexValue<ScriptAsset>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<ScriptAsset>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<ScriptAsset>The constructed value.

ArcMutexValue<ShaderBuffer>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<ShaderBuffer>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<ShaderBuffer>The constructed value.

ArcMutexValue<ColorMaterial>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<ColorMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<ColorMaterial>The constructed value.

ArcMutexValue<SpriteMeshMaterial>

Opaque Type. 🔒

Description

Stores an [Arc<Mutex<AssetOrHandle<T>>>].

This intermediary type exists largely to enable reflect(opaque).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ArcMutexValue<SpriteMeshMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArcMutexValue<SpriteMeshMaterial>The constructed value.

HandleTemplate<Image>

Path

  1. AssetPath

Handle

  1. Handle<Image>

Value

  1. ArcMutexValue<Image>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<Image>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<Image>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Image>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Image>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Image>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Image>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Image>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Image>No Documentation 🚧

HandleTemplate<TextureAtlasLayout>

Path

  1. AssetPath

Handle

  1. Handle<TextureAtlasLayout>

Value

  1. ArcMutexValue<TextureAtlasLayout>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<TextureAtlasLayout>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<TextureAtlasLayout>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<TextureAtlasLayout>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<TextureAtlasLayout>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<TextureAtlasLayout>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<TextureAtlasLayout>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<TextureAtlasLayout>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<TextureAtlasLayout>No Documentation 🚧

HandleTemplate<Mesh>

Path

  1. AssetPath

Handle

  1. Handle<Mesh>

Value

  1. ArcMutexValue<Mesh>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<Mesh>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<Mesh>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Mesh>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Mesh>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Mesh>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Mesh>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<Mesh>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<Mesh>No Documentation 🚧

HandleTemplate<ScriptAsset>

Path

  1. AssetPath

Handle

  1. Handle<ScriptAsset>

Value

  1. ArcMutexValue<ScriptAsset>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<ScriptAsset>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<ScriptAsset>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ScriptAsset>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ScriptAsset>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ScriptAsset>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ScriptAsset>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ScriptAsset>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ScriptAsset>No Documentation 🚧

HandleTemplate<ShaderBuffer>

Path

  1. AssetPath

Handle

  1. Handle<ShaderBuffer>

Value

  1. ArcMutexValue<ShaderBuffer>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<ShaderBuffer>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<ShaderBuffer>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ShaderBuffer>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ShaderBuffer>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ShaderBuffer>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ShaderBuffer>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ShaderBuffer>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ShaderBuffer>No Documentation 🚧

HandleTemplate<ColorMaterial>

Path

  1. AssetPath

Handle

  1. Handle<ColorMaterial>

Value

  1. ArcMutexValue<ColorMaterial>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<ColorMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<ColorMaterial>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ColorMaterial>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ColorMaterial>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ColorMaterial>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ColorMaterial>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<ColorMaterial>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<ColorMaterial>No Documentation 🚧

HandleTemplate<SpriteMeshMaterial>

Path

  1. AssetPath

Handle

  1. Handle<SpriteMeshMaterial>

Value

  1. ArcMutexValue<SpriteMeshMaterial>

Description

A [Template] that produces a [Handle].

How asset paths are resolved in templates

When a type with a [Handle<T>] field derives [FromTemplate], that field is replaced by its template type, [HandleTemplate<T>], when created via BSN. We can see that [HandleTemplate<T>] has the following trait impl block:

impl<I: Into<AssetPath<'static>>, T: Asset> From<I> for HandleTemplate<T> {
    fn from(value: I) -> Self {
        Self::Path(value.into())
    }
}

[AssetPath<'static>] implements [From<&'static str>]. Because of that, assigning a string literal to a Handle<T> field automatically converts it into [HandleTemplate<T>::Path] with that asset path when used in the bsn! macro. Calls to bsn! automatically insert .into() conversions, and due to Rust’s blanket impl that turns [From] trait impls into their [Into] equivalents, the conversion from &'static str to AssetPath<'static> is handled automatically. Finally, the [HandleTemplate<T>::Path] generated gets converted to a [Handle<T>] during scene initialization, as the asset is loaded from the given path, and the resulting handle is assigned to the field, pointing to the asset that was found at the file path in our original string.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Handle.newNo Documentation 🚧
Path.newNo Documentation 🚧
Value.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HandleTemplate<SpriteMeshMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHandleTemplate<SpriteMeshMaterial>The constructed value.

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<SpriteMeshMaterial>::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<SpriteMeshMaterial>No Documentation 🚧

Path.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<SpriteMeshMaterial>::Path>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<SpriteMeshMaterial>No Documentation 🚧

Value.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<HandleTemplate<SpriteMeshMaterial>::Value>No Documentation 🚧

Returns

NameTypeDocumentation
returnHandleTemplate<SpriteMeshMaterial>No Documentation 🚧

AssetId<ScriptAsset>

Index

Uuid

Description

A unique runtime-only identifier for an [Asset]. This is cheap to [Copy]/[Clone] and is not directly tied to the lifetime of the Asset. This means it can point to an [Asset] that no longer exists.

For an identifier tied to the lifetime of an asset, see Handle.

For an “untyped” / “generic-less” id, see [UntypedAssetId].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Index.newNo Documentation 🚧
Uuid.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AssetId<ScriptAsset>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAssetId<ScriptAsset>The constructed value.

Index.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AssetId<ScriptAsset>::Index>No Documentation 🚧

Returns

NameTypeDocumentation
returnAssetId<ScriptAsset>No Documentation 🚧

Uuid.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AssetId<ScriptAsset>::Uuid>No Documentation 🚧

Returns

NameTypeDocumentation
returnAssetId<ScriptAsset>No Documentation 🚧

Handle<A>

Opaque Type. 🔒

Description

A handle to an asset of type A.

Instantiations

The arguments this generic type is used with.

audio

The types and functions in the audio namespace, as returned by import_namespace("audio").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
PlaybackSettingsInitial settings to be used when audio starts playing. If you would like to control the audio whi...
PlaybackModeThe way Bevy manages the sound playback.
SpatialScaleA scale factor applied to the positions of audio sources and listeners for spatial audio. Defaul...
VolumeA [`Volume`] represents an audio source’s volume level. To create a new [`Volume`] from a linear ...

PlaybackSettings

PlaybackSettings

Description

Initial settings to be used when audio starts playing.

If you would like to control the audio while it is playing, query for the AudioSink or SpatialAudioSink components. Changes to this component will not be applied to already-playing audio.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
loopingSettings that repeat the sound forever.
with_speedA copy of the settings with the starting speed set to `speed`, where `1` is normal speed.
with_volumeA copy of the settings with the starting volume set to `linear`, where `1` is the original volume an...
with_spatialA copy of the settings with spatial audio turned on or off.
despawnSettings that play the sound once, then despawn the entity.
onceSettings that play the sound once, then do nothing.
removeSettings that play the sound once, then remove the audio components from the entity.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

looping

Settings that repeat the sound forever.

Arguments

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

with_speed

A copy of the settings with the starting speed set to speed, where 1 is normal speed.

Arguments

NameTypeDocumentation
_selfPlaybackSettingsNo Documentation 🚧
speedF32No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

with_volume

A copy of the settings with the starting volume set to linear, where 1 is the original volume and 0 is silent.

Arguments

NameTypeDocumentation
_selfPlaybackSettingsNo Documentation 🚧
linearF32No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

with_spatial

A copy of the settings with spatial audio turned on or off.

Arguments

NameTypeDocumentation
_selfPlaybackSettingsNo Documentation 🚧
spatialBoolNo Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

despawn

Settings that play the sound once, then despawn the entity.

Arguments

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

once

Settings that play the sound once, then do nothing.

Arguments

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

remove

Settings that play the sound once, then remove the audio components from the entity.

Arguments

Returns

NameTypeDocumentation
returnPlaybackSettingsNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<PlaybackSettings>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referencePlaybackSettingsThe constructed value.

PlaybackMode

Once

Loop

Despawn

Remove

Description

The way Bevy manages the sound playback.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Despawn.newNo Documentation 🚧
Loop.newNo Documentation 🚧
Once.newNo Documentation 🚧
Remove.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<PlaybackMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referencePlaybackModeThe constructed value.

Despawn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PlaybackMode::Despawn>No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackModeNo Documentation 🚧

Loop.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PlaybackMode::Loop>No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackModeNo Documentation 🚧

Once.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PlaybackMode::Once>No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackModeNo Documentation 🚧

Remove.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PlaybackMode::Remove>No Documentation 🚧

Returns

NameTypeDocumentation
returnPlaybackModeNo Documentation 🚧

SpatialScale

SpatialScale

  1. Vec3

Description

A scale factor applied to the positions of audio sources and listeners for spatial audio.

Default is Vec3::ONE.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SpatialScale>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpatialScaleThe constructed value.

Volume

Linear

  1. F32

Decibels

  1. F32

Description

A [Volume] represents an audio source’s volume level.

To create a new [Volume] from a linear scale value, use [Volume::Linear].

To create a new [Volume] from decibels, use [Volume::Decibels].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Decibels.newNo Documentation 🚧
Linear.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Volume>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVolumeThe constructed value.

Decibels.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Volume::Decibels>No Documentation 🚧

Returns

NameTypeDocumentation
returnVolumeNo Documentation 🚧

Linear.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Volume::Linear>No Documentation 🚧

Returns

NameTypeDocumentation
returnVolumeNo Documentation 🚧

bevy_platform

The types and functions in the bevy_platform namespace, as returned by import_namespace("bevy_platform").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
Arc<Unknown>No Documentation 🚧
Hashed<Cow, Unknown>No Documentation 🚧

Arc<TypeId(0x21563c724267e320d8e5fce97050cf22)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Arc<TypeId(0x21563c724267e320d8e5fce97050cf22)>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceArc<TypeId(0x21563c724267e320d8e5fce97050cf22)>The constructed value.

Hashed<Cow, TypeId(0x4ee5fc7c26dac803f8abc5b33940c653)>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Hashed<Cow, TypeId(0x4ee5fc7c26dac803f8abc5b33940c653)>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHashed<Cow, TypeId(0x4ee5fc7c26dac803f8abc5b33940c653)>The constructed value.

bms

The types and functions in the bms namespace, as returned by import_namespace("bms").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
EnumVariantRefA reference to a variant of an enum, independent of any value of that enum. This is what scripts ...
ScriptBundleRegistrationA reference to a bundle type’s reflection registration, i.e. a type with `ReflectBundle` type data....
ScriptComponentRegistrationA reference to a component type’s reflection registration. In general think of this as a handle t...
ScriptQueryBuilderThe query builder is used to build ECS queries which retrieve spefific components filtered by speci...
ScriptResourceRegistrationA reference to a resource type’s reflection registration. In general think of this as a handle to...
ScriptTypeRegistrationA reference to a type which is not a `Resource` or `Component`. In general think of this as a han...
ScriptEventRegistrationA handle to a script registered event type.
ScriptRunConditionA run condition of a script system, evaluated in Rust without calling into the script, see [`ScriptSystemBuilder::run_if`].
ScriptSystemBuilderA builder for systems living in scripts
RecipientsDescribes the designated recipients of a script event
ScriptAttachmentSpecifies a unique attachment of a script. These attachments are mapped to [`bevy_mod_scripting_core::ContextKey`]’s depending on the context policy used.
ReflectScheduleA reflectable schedule.
ReflectSystemA reflectable system.
ReflectSystemSetA reflectable system set: a set node of a schedule graph, or a set scripts put and order their syst...
LanguageRepresents a scripting language. Languages which compile into another language should use the targe...
ScriptAssetRepresents a script loaded into memory as an asset
FunctionArgInfoInformation about a function argument.
FunctionInfoInformation about a function.
FunctionReturnInfoInformation about a function return value.
InteropErrorAn error occurring when converting between rust and a script context.
FunctionScopeWhere a function lives, for its documentation and errors
ScriptQueryResultA result from a query. Scripts receive it as a plain list, the entity followed by the components ...
DynamicComponentA dynamic script component
VariadicTupleA tuple variant of script value
CallbackLabelA string which disallows common invalid characters in callback labels, particularly at the start o...
ScriptAssetModifiedMessageEmitted when a script asset is modified and all its attachments require re-loading
ScriptCallbackMessageA callback message meant to trigger a callback in a subset/set of scripts in the world with the giv...
ScriptLifecycleMessageEmitted when a script is attached or detached. Both are one message type, so the pipeline process...
ScriptComponentA component which identifies the scripts existing on an entity. Event handlers search for compone...
ReflectableScheduleLabelNo Documentation 🚧

Values

NameType
conditionsStaticTypeRef
worldWorld

Functions

For function details and documentation, click on the function link.

FunctionSummary
constructAttempts to construct the given type, given an arbitrary map of values. Unlike `Type.new`, this wor...
current_entityThe entity the running script is attached to, or nil if it isn’t attached to one.
current_scriptThe asset handle of the running script, or nil outside of a script callback. If the asset is ever u...
log_debugLogs a `Debug` level message to the console * `message`: the message to log
log_errorLogs a `Error` level message to the console * `message`: the message to log
log_infoLogs a `Information` level message to the console
log_traceLogs a `Trace` level message to the console * `message`: the message to log
log_warnLogs a `Warning` level message to the console * `message`: the message to log
pack_argsPacks, a variable amount of values, into a single list.
queue_script_callbackQueues a callback to run on other scripts as soon as the current callback finishes, in the same fram...
run_script_callbackRuns a callback on other scripts immediately, and returns what it returned. For example `run_script_callback(“take_damage”, ScriptAttachment.new_entity_script(enemy, script), 10)` calls `take_...
system_builderCreates a new script system builder, which can be used to add new systems to the world.
unpack_argsUnpacks, a list of values, into many separate values.

EnumVariantRef

EnumVariantRef

Description

A reference to a variant of an enum, independent of any value of that enum.

This is what scripts see when accessing MyEnum.Variant, it can be compared to the result of value:variant() and used to construct values of the variant.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a value of this enum variant from a table of its fields. Missing fields are filled in fro...
eqChecks whether two variants are the same variant of the same enum, or whether a value is in this var...
variant_nameRetrieves the name of the variant.

new

Constructs a value of this enum variant from a table of its fields. Missing fields are filled in from the enum’s default if it is this variant, then from the defaults of the fields’ types.

Arguments

NameTypeDocumentation
variantEnumVariantRefThe variant to construct.
payloadHashMap<String, ScriptValue>The fields of the variant, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectReferenceThe constructed value.

eq

Checks whether two variants are the same variant of the same enum, or whether a value is in this variant.

Arguments

NameTypeDocumentation
variantEnumVariantRefThe variant.
otherScriptValueThe variant or value to compare with.

Returns

NameTypeDocumentation
equalBoolWhether the other value is the same variant.

variant_name

Retrieves the name of the variant.

Arguments

NameTypeDocumentation
variantEnumVariantRefThe variant.

Returns

NameTypeDocumentation
variant_nameStringThe name of the variant.

ScriptBundleRegistration

Opaque Type. 🔒

Description

A reference to a bundle type’s reflection registration, i.e. a type with ReflectBundle type data.

In general think of this as a handle to a type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
type_nameRetrieves the name of the type.
namespaceRetrieves the script namespace of the type, by default the name of the crate defining it. Types in t...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptBundleRegistrationThe type registration.

Returns

NameTypeDocumentation
short_nameStrThe short name of the

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptBundleRegistrationThe type registration.

Returns

NameTypeDocumentation
type_nameStrThe name of the type.

namespace

Retrieves the script namespace of the type, by default the name of the crate defining it. Types in the root namespace have the empty string as namespace.

Arguments

NameTypeDocumentation
registrationScriptBundleRegistrationThe type registration.

Returns

NameTypeDocumentation
namespaceStringThe namespace of the type.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptBundleRegistration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptBundleRegistrationThe constructed value.

ScriptComponentRegistration

ScriptComponentRegistration

Description

A reference to a component type’s reflection registration.

In general think of this as a handle to a type.

Not to be confused with script registered dynamic components, although this can point to a script registered component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
type_nameRetrieves the name of the type.
namespaceRetrieves the script namespace of the type, by default the name of the crate defining it. Types in t...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptComponentRegistrationThe type registration.

Returns

NameTypeDocumentation
short_nameStrThe short name of the

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptComponentRegistrationThe type registration.

Returns

NameTypeDocumentation
type_nameStrThe name of the type.

namespace

Retrieves the script namespace of the type, by default the name of the crate defining it. Types in the root namespace have the empty string as namespace.

Arguments

NameTypeDocumentation
registrationScriptComponentRegistrationThe type registration.

Returns

NameTypeDocumentation
namespaceStringThe namespace of the type.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptComponentRegistration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptComponentRegistrationThe constructed value.

ScriptQueryBuilder

Opaque Type. 🔒

Description

The query builder is used to build ECS queries which retrieve spefific components filtered by specific conditions.

For example:

builder.component(componentA)
    .component(componentB)
    .with(componentC)
    .without(componentD)  

Will retrieve entities which:

  • Have componentA
  • Have componentB
  • Have componentC
  • Do not have componentD

As well as references to components:

  • componentA
  • componentB

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
buildBuilds the query and retrieves the entities and component references. Each result is a list of the ...
optionalAdds a component to be retrieved by the query, which entities don’t need to have, it is nil for thos...
optional_readLike `optional`, but the component can only be read.
changedOnly matches entities whose component was changed since the system last ran (outside of systems: sin...
componentAdds a component to be retrieved by the query
addedOnly matches entities whose component was added since the system last ran (outside of systems: since...
component_readAdds a component to be retrieved by the query, which can only be read. Script systems reading a com...
withAdds a component to filter the query by. This component will NOT be retrieved.
withoutAdds a component to filter the query by. This component will NOT be retrieved.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

build

Builds the query and retrieves the entities and component references.

Each result is a list of the entity followed by the components in the order they were added to the query, i.e. local entity, a, b = result[1], result[2], result[3] in Lua, absent optional components are nil.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to build.

Returns

NameTypeDocumentation
resultVec<(Entity, …Optional<ReflectReference>)>The entities and component references that match the query.

optional

Adds a component to be retrieved by the query, which entities don’t need to have, it is nil for those which don’t.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
componentScriptComponentRegistrationThe component to add

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

optional_read

Like optional, but the component can only be read.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
componentScriptComponentRegistrationThe component to add

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

changed

Only matches entities whose component was changed since the system last ran (outside of systems: since the last update). This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the filter to
componentScriptComponentRegistrationThe component to filter by

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the filter added

component

Adds a component to be retrieved by the query

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
componentsScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

added

Only matches entities whose component was added since the system last ran (outside of systems: since the last update). This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the filter to
componentScriptComponentRegistrationThe component to filter by

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the filter added

component_read

Adds a component to be retrieved by the query, which can only be read.

Script systems reading a component can run in parallel with each other, unlike ones writing it.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
componentScriptComponentRegistrationThe component to add

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

with

Adds a component to filter the query by. This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
withScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

without

Adds a component to filter the query by. This component will NOT be retrieved.

Arguments

NameTypeDocumentation
queryScriptQueryBuilderThe query to add the component to
withoutScriptComponentRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
queryScriptQueryBuilderThe query with the component added

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptQueryBuilder>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptQueryBuilderThe constructed value.

ScriptResourceRegistration

ScriptResourceRegistration

Description

A reference to a resource type’s reflection registration.

In general think of this as a handle to a type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
namespaceRetrieves the script namespace of the type, by default the name of the crate defining it. Types in t...
type_nameRetrieves the name of the type.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe type registration.

Returns

NameTypeDocumentation
short_nameStrThe short name of the

namespace

Retrieves the script namespace of the type, by default the name of the crate defining it. Types in the root namespace have the empty string as namespace.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe type registration.

Returns

NameTypeDocumentation
namespaceStringThe namespace of the type.

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe type registration.

Returns

NameTypeDocumentation
type_nameStrThe name of the type.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptResourceRegistration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptResourceRegistrationThe constructed value.

ScriptTypeRegistration

Opaque Type. 🔒

Description

A reference to a type which is not a Resource or Component.

In general think of this as a handle to a type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
namespaceRetrieves the script namespace of the type, by default the name of the crate defining it. Types in t...
type_nameRetrieves the name of the type.
short_nameRetrieves the short name of the type. The short name is a more human-readable version of the type na...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

namespace

Retrieves the script namespace of the type, by default the name of the crate defining it. Types in the root namespace have the empty string as namespace.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type registration.

Returns

NameTypeDocumentation
namespaceStringThe namespace of the type.

type_name

Retrieves the name of the type.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type registration.

Returns

NameTypeDocumentation
type_nameStringThe name of the type.

short_name

Retrieves the short name of the type. The short name is a more human-readable version of the type name.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type registration.

Returns

NameTypeDocumentation
short_nameStringThe short name of the

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptTypeRegistration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptTypeRegistrationThe constructed value.

ScriptEventRegistration

Opaque Type. 🔒

Description

A handle to a script registered event type.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
short_nameRetrieves the name of the event within its namespace, i.e. `Hit` for `script.game.Hit`.
namespaceRetrieves the script namespace the event was registered in, i.e. `script.game` for `script.game.Hit`...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

short_name

Retrieves the name of the event within its namespace, i.e. Hit for script.game.Hit.

Arguments

NameTypeDocumentation
registrationScriptEventRegistrationThe event registration.

Returns

NameTypeDocumentation
short_nameStringThe name of the event.

namespace

Retrieves the script namespace the event was registered in, i.e. script.game for script.game.Hit.

Arguments

NameTypeDocumentation
registrationScriptEventRegistrationThe event registration.

Returns

NameTypeDocumentation
namespaceStringThe namespace of the event.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptEventRegistration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptEventRegistrationThe constructed value.

ScriptRunCondition

Opaque Type. 🔒

Description

A run condition of a script system, evaluated in Rust without calling into the script, see [ScriptSystemBuilder::run_if].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
run_onceHolds the first time it is evaluated only. Returns: * `condition`: The condition.
any_with_componentHolds if any entity has the component.
or_Holds if either condition holds, the second one is only evaluated if the first one doesn’t hold.
resource_existsHolds if the resource exists.
on_timerHolds once every given amount of seconds, measured with `Time`.
resource_changedHolds if the resource changed since the system last ran, doesn’t hold if it doesn’t exist.
resource_addedHolds if the resource was added since the system last ran.
not_Holds if the condition doesn’t hold. Named `not_` as `not` is a keyword in Lua.
and_Holds if both conditions hold, the second one is only evaluated if the first one holds.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

run_once

Holds the first time it is evaluated only.

Returns:

  • condition: The condition.

Arguments

Returns

NameTypeDocumentation
returnScriptRunConditionNo Documentation 🚧

any_with_component

Holds if any entity has the component.

Arguments

NameTypeDocumentation
componentScriptComponentRegistrationThe component.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe condition.

or_

Holds if either condition holds, the second one is only evaluated if the first one doesn’t hold.

Arguments

NameTypeDocumentation
aScriptRunConditionThe first condition.
bScriptRunConditionThe second condition.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe combined condition.

resource_exists

Holds if the resource exists.

Arguments

NameTypeDocumentation
resourceScriptResourceRegistrationThe resource.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe condition.

on_timer

Holds once every given amount of seconds, measured with Time.

Arguments

NameTypeDocumentation
secondsF64The interval in seconds.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe condition.

resource_changed

Holds if the resource changed since the system last ran, doesn’t hold if it doesn’t exist.

Arguments

NameTypeDocumentation
resourceScriptResourceRegistrationThe resource.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe condition.

resource_added

Holds if the resource was added since the system last ran.

Arguments

NameTypeDocumentation
resourceScriptResourceRegistrationThe resource.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe condition.

not_

Holds if the condition doesn’t hold. Named not_ as not is a keyword in Lua.

Arguments

NameTypeDocumentation
conditionScriptRunConditionThe condition.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe negated condition.

and_

Holds if both conditions hold, the second one is only evaluated if the first one holds.

Arguments

NameTypeDocumentation
aScriptRunConditionThe first condition.
bScriptRunConditionThe second condition.

Returns

NameTypeDocumentation
conditionScriptRunConditionThe combined condition.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptRunCondition>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptRunConditionThe constructed value.

ScriptSystemBuilder

Opaque Type. 🔒

Description

A builder for systems living in scripts

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
run_ifOnly runs the system if the condition holds, see `bms.conditions`. All conditions must hold for the ...
before_script_systemSpecifies the system is to run *before* the script system with the given callback label of the given...
after_setSpecifies the system is to run *after* the given set. Sets are registered by scripts with `register_new_system_set`, game sets are found with `get_...
exclusiveSpecifies the system is to run exclusively, meaning it can access anything, but will not run in para...
before_setSpecifies the system is to run *before* the given set. Sets are registered by scripts with `register_new_system_set`, game sets are found with `get_...
in_setPuts the system in the given set, ordering the set orders the system. Sets are registered by scripts...
beforeSpecifies the system is to run *before* the given system. Note: this is an experimental feature, an...
resource_readRequests the system have read only access to the given resource. The resource will be added to the l...
after_script_systemSpecifies the system is to run *after* the script system with the given callback label of the given ...
afterSpecifies the system is to run *after* the given system Note: this is an experimental feature, and ...
resourceRequests the system have access to the given resource. The resource will be added to the list of arg...
queryAdds a query to the system builder.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

run_if

Only runs the system if the condition holds, see bms.conditions. All conditions must hold for the system to run.

Conditions are evaluated without calling into the script.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the condition to.
conditionScriptRunConditionThe condition.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the condition added.

before_script_system

Specifies the system is to run before the script system with the given callback label of the given script. That system must have been added before this one.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
labelStringThe callback label of the other script system.
attachmentScriptAttachmentThe script the other script system belongs to.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

after_set

Specifies the system is to run after the given set. Sets are registered by scripts with register_new_system_set, game sets are found with get_system_set_by_name.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
setReflectSystemSetThe system set.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

exclusive

Specifies the system is to run exclusively, meaning it can access anything, but will not run in parallel with other systems.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to make exclusive.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder that is now exclusive.

before_set

Specifies the system is to run before the given set. Sets are registered by scripts with register_new_system_set, game sets are found with get_system_set_by_name.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
setReflectSystemSetThe system set.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

in_set

Puts the system in the given set, ordering the set orders the system. Sets are registered by scripts with register_new_system_set, game sets are found with get_system_set_by_name.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to put in the set.
setReflectSystemSetThe system set.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder in the set.

before

Specifies the system is to run before the given system.

Note: this is an experimental feature, and the ordering might not work correctly for script initialized systems

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
systemReflectSystemThe system to run before.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

resource_read

Requests the system have read only access to the given resource. The resource will be added to the list of arguments of the callback in the order they’re provided.

Script systems reading a resource can run in parallel with each other, unlike ones writing it.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the resource to.
resourceScriptResourceRegistrationThe resource to add.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the resource added.

after_script_system

Specifies the system is to run after the script system with the given callback label of the given script. That system must have been added before this one.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
labelStringThe callback label of the other script system.
attachmentScriptAttachmentThe script the other script system belongs to.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

after

Specifies the system is to run after the given system

Note: this is an experimental feature, and the ordering might not work correctly for script initialized systems

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the dependency to.
systemReflectSystemThe system to run after.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the dependency added.

resource

Requests the system have access to the given resource. The resource will be added to the list of arguments of the callback in the order they’re provided.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the resource to.
resourceScriptResourceRegistrationThe resource to add.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the resource added.

query

Adds a query to the system builder.

Arguments

NameTypeDocumentation
builderScriptSystemBuilderThe system builder to add the query to.
queryScriptQueryBuilderThe query to add.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder with the query added.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptSystemBuilder>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptSystemBuilderThe constructed value.

Recipients

AllScripts

AllContexts

ScriptEntity

  1. Handle<ScriptAsset>
  2. Entity

StaticScript

  1. Handle<ScriptAsset>

Description

Describes the designated recipients of a script event

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
all_scriptsTargets every loaded script, once per script even if scripts share a context. Returns: * `recipients`: The recipients.
entity_scriptTargets a single script attached to an entity.
all_contextsTargets every loaded context once, i.e. scripts sharing a context only run the callback once. Retur...
static_scriptTargets a single static script.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AllContexts.newNo Documentation 🚧
AllScripts.newNo Documentation 🚧
ScriptEntity.newNo Documentation 🚧
StaticScript.newNo Documentation 🚧

all_scripts

Targets every loaded script, once per script even if scripts share a context.

Returns:

  • recipients: The recipients.

Arguments

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

entity_script

Targets a single script attached to an entity.

Arguments

NameTypeDocumentation
entityEntityThe entity the script is attached to.
scriptHandle<ScriptAsset>The script asset.

Returns

NameTypeDocumentation
recipientsRecipientsThe recipients.

all_contexts

Targets every loaded context once, i.e. scripts sharing a context only run the callback once.

Returns:

  • recipients: The recipients.

Arguments

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

static_script

Targets a single static script.

Arguments

NameTypeDocumentation
scriptHandle<ScriptAsset>The script asset.

Returns

NameTypeDocumentation
recipientsRecipientsThe recipients.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Recipients>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRecipientsThe constructed value.

AllContexts.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Recipients::AllContexts>No Documentation 🚧

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

AllScripts.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Recipients::AllScripts>No Documentation 🚧

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

ScriptEntity.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Recipients::ScriptEntity>No Documentation 🚧

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

StaticScript.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Recipients::StaticScript>No Documentation 🚧

Returns

NameTypeDocumentation
returnRecipientsNo Documentation 🚧

ScriptAttachment

EntityScript

  1. Entity
  2. Handle<ScriptAsset>

StaticScript

  1. Handle<ScriptAsset>

Description

Specifies a unique attachment of a script. These attachments are mapped to [bevy_mod_scripting_core::ContextKey]’s depending on the context policy used.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
new_entity_scriptCreates a new script attachment descriptor for an entity attached script.
new_static_scriptCreates a new script attachment descriptor from a script asset.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
EntityScript.newNo Documentation 🚧
StaticScript.newNo Documentation 🚧

new_entity_script

Creates a new script attachment descriptor for an entity attached script.

Arguments

NameTypeDocumentation
entityEntityThe entity to attach the script to.
scriptHandle<ScriptAsset>The script asset to attach to the entity.

Returns

NameTypeDocumentation
attachmentScriptAttachmentThe new script attachment for the entity.

new_static_script

Creates a new script attachment descriptor from a script asset.

Arguments

NameTypeDocumentation
scriptHandle<ScriptAsset>The script asset to create the attachment from.

Returns

NameTypeDocumentation
attachmentScriptAttachmentThe new script attachment.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptAttachment>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptAttachmentThe constructed value.

EntityScript.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScriptAttachment::EntityScript>No Documentation 🚧

Returns

NameTypeDocumentation
returnScriptAttachmentNo Documentation 🚧

StaticScript.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScriptAttachment::StaticScript>No Documentation 🚧

Returns

NameTypeDocumentation
returnScriptAttachmentNo Documentation 🚧

ReflectSchedule

ReflectSchedule

Description

A reflectable schedule.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
render_dotRenders the schedule as a dot graph string. Useful for debugging scheduling.
get_system_by_nameRetrieves the system with the given name in the schedule
systemsRetrieves all the systems in the schedule.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

render_dot

Renders the schedule as a dot graph string.

Useful for debugging scheduling.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to render.

Returns

NameTypeDocumentation
dotStringThe dot graph string.

get_system_by_name

Retrieves the system with the given name in the schedule

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to retrieve the system from.
nameStringThe identifier or full path of the system to retrieve.

Returns

NameTypeDocumentation
systemOptional<ReflectSystem>The system with the given name, if it exists.

systems

Retrieves all the systems in the schedule.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to retrieve the systems from.

Returns

NameTypeDocumentation
systemsVec<ReflectSystem>The systems in the schedule.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReflectSchedule>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectScheduleThe constructed value.

ReflectSystem

Opaque Type. 🔒

Description

A reflectable system.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
pathRetrieves the full path of the system
identifierRetrieves the identifier of the system
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

path

Retrieves the full path of the system

Arguments

NameTypeDocumentation
systemReflectSystemThe system to retrieve the path from.

Returns

NameTypeDocumentation
pathStringThe full path of the system, e.g. my_crate::systems::my_system<T>

identifier

Retrieves the identifier of the system

Arguments

NameTypeDocumentation
systemReflectSystemThe system to retrieve the identifier from.

Returns

NameTypeDocumentation
identifierStringThe identifier of the system, e.g. my_system

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReflectSystem>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectSystemThe constructed value.

ReflectSystemSet

Opaque Type. 🔒

Description

A reflectable system set: a set node of a schedule graph, or a set scripts put and order their systems in.

Bevy does not expose the interned sets of a schedule graph, so set nodes of a graph only have a node id, while sets made from an interned set (i.e. the ones scripts use) only have the set.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
nameRetrieves the name of the system set
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

name

Retrieves the name of the system set

Arguments

NameTypeDocumentation
setReflectSystemSetThe system set to retrieve the name from.

Returns

NameTypeDocumentation
nameStringThe debug name of the set, e.g. TransformSystems::Propagate or ScriptNamedSet("script.my_game.ai")

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReflectSystemSet>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectSystemSetThe constructed value.

Language

Lua

Rune

External

Unknown

Description

Represents a scripting language. Languages which compile into another language should use the target language as their language.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
External.newNo Documentation 🚧
Lua.newNo Documentation 🚧
Rune.newNo Documentation 🚧
Unknown.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Language>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceLanguageThe constructed value.

External.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Language::External>No Documentation 🚧

Returns

NameTypeDocumentation
returnLanguageNo Documentation 🚧

Lua.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Language::Lua>No Documentation 🚧

Returns

NameTypeDocumentation
returnLanguageNo Documentation 🚧

Rune.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Language::Rune>No Documentation 🚧

Returns

NameTypeDocumentation
returnLanguageNo Documentation 🚧

Unknown.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Language::Unknown>No Documentation 🚧

Returns

NameTypeDocumentation
returnLanguageNo Documentation 🚧

ScriptAsset

Opaque Type. 🔒

Description

Represents a script loaded into memory as an asset

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueScriptAssetThe asset value.

Returns

NameTypeDocumentation
handleHandle<ScriptAsset>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<ScriptAsset>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<ScriptAsset>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<ScriptAsset>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptAsset>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptAssetThe constructed value.

FunctionArgInfo

FunctionArgInfo

Description

Information about a function argument.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FunctionArgInfo>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFunctionArgInfoThe constructed value.

FunctionInfo

FunctionInfo

Description

Information about a function.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FunctionInfo>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFunctionInfoThe constructed value.

FunctionReturnInfo

FunctionReturnInfo

Description

Information about a function return value.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FunctionReturnInfo>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFunctionReturnInfoThe constructed value.

InteropError

Opaque Type. 🔒

Description

An error occurring when converting between rust and a script context.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InteropError>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInteropErrorThe constructed value.

FunctionScope

OnType

  1. TypeId

Member

Builtin

Description

Where a function lives, for its documentation and errors

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Builtin.newNo Documentation 🚧
Member.newNo Documentation 🚧
OnType.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FunctionScope>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFunctionScopeThe constructed value.

Builtin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FunctionScope::Builtin>No Documentation 🚧

Returns

NameTypeDocumentation
returnFunctionScopeNo Documentation 🚧

Member.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FunctionScope::Member>No Documentation 🚧

Returns

NameTypeDocumentation
returnFunctionScopeNo Documentation 🚧

OnType.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FunctionScope::OnType>No Documentation 🚧

Returns

NameTypeDocumentation
returnFunctionScopeNo Documentation 🚧

ScriptQueryResult

Opaque Type. 🔒

Description

A result from a query.

Scripts receive it as a plain list, the entity followed by the components in the order they were added to the query, i.e. {entity, a, b} in Lua, with nil for absent optional components. Nothing is allocated for the result itself.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptQueryResult>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptQueryResultThe constructed value.

DynamicComponent

DynamicComponent

Description

A dynamic script component

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<DynamicComponent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDynamicComponentThe constructed value.

VariadicTuple

Opaque Type. 🔒

Description

A tuple variant of script value

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<VariadicTuple>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVariadicTupleThe constructed value.

CallbackLabel

CallbackLabel

  1. String

Description

A string which disallows common invalid characters in callback labels, particularly at the start of the string

a valid callback label starts with a letter or underscore, and contains only ascii characters, as well as disallows some common keywords

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<CallbackLabel>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCallbackLabelThe constructed value.

ScriptAssetModifiedMessage

ScriptAssetModifiedMessage

  1. AssetId<ScriptAsset>

Description

Emitted when a script asset is modified and all its attachments require re-loading

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptAssetModifiedMessage>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptAssetModifiedMessageThe constructed value.

ScriptCallbackMessage

ScriptCallbackMessage

Description

A callback message meant to trigger a callback in a subset/set of scripts in the world with the given arguments

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptCallbackMessage>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptCallbackMessageThe constructed value.

ScriptLifecycleMessage

Attached

  1. ScriptAttachment

Detached

  1. ScriptAttachment

Description

Emitted when a script is attached or detached.

Both are one message type, so the pipeline processes them in the order they were written.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Attached.newNo Documentation 🚧
Detached.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptLifecycleMessage>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptLifecycleMessageThe constructed value.

Attached.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScriptLifecycleMessage::Attached>No Documentation 🚧

Returns

NameTypeDocumentation
returnScriptLifecycleMessageNo Documentation 🚧

Detached.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScriptLifecycleMessage::Detached>No Documentation 🚧

Returns

NameTypeDocumentation
returnScriptLifecycleMessageNo Documentation 🚧

ScriptComponent

ScriptComponent

  1. Vec<Handle<ScriptAsset>>

Description

A component which identifies the scripts existing on an entity.

Event handlers search for components with this component to figure out which scripts to run and on which entities.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptComponent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptComponentThe constructed value.

ReflectableScheduleLabel

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReflectableScheduleLabel>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectableScheduleLabelThe constructed value.

construct

Attempts to construct the given type, given an arbitrary map of values.

Unlike Type.new, this works for every type, including ones with a new function of their own. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types, as for Type.new.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationScriptComponentRegistration
payloadHashMap<String, ScriptValue>The values to use to construct the type, keyed by field name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectReferenceThe constructed type.

current_entity

The entity the running script is attached to, or nil if it isn’t attached to one.

Arguments

Returns

NameTypeDocumentation
entityOptional<Entity>The entity, or nil.

current_script

The asset handle of the running script, or nil outside of a script callback.

If the asset is ever unloaded, the handle will be less useful.

Arguments

Returns

NameTypeDocumentation
scriptOptional<Handle<ScriptAsset>>The handle, or nil.

log_debug

Logs a Debug level message to the console

  • message: the message to log

Arguments

NameTypeDocumentation
messageStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

log_error

Logs a Error level message to the console

  • message: the message to log

Arguments

NameTypeDocumentation
messageStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

log_info

Logs a Information level message to the console

Arguments

NameTypeDocumentation
messageStringthe message to log

Returns

NameTypeDocumentation
return()No Documentation 🚧

log_trace

Logs a Trace level message to the console

  • message: the message to log

Arguments

NameTypeDocumentation
messageStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

log_warn

Logs a Warning level message to the console

  • message: the message to log

Arguments

NameTypeDocumentation
messageStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

pack_args

Packs, a variable amount of values, into a single list.

Arguments

NameTypeDocumentation
tupleThe tuple of values to curry

Returns

NameTypeDocumentation
valuesVec<ScriptValue>The list of values destructured from the tuple

queue_script_callback

Queues a callback to run on other scripts as soon as the current callback finishes, in the same frame.

Unlike run_script_callback, this works for any script, including the calling script itself and scripts sharing its context. Queued callbacks run in the order they were queued, and their errors are reported as script errors instead of being raised here.

Arguments

NameTypeDocumentation
labelStringThe name of the callback to run.
targetScriptAttachmentRecipients
argsThe arguments to pass to the callback.

Returns

NameTypeDocumentation
result()Nothing if the callback was queued.

run_script_callback

Runs a callback on other scripts immediately, and returns what it returned.

For example run_script_callback("take_damage", ScriptAttachment.new_entity_script(enemy, script), 10) calls take_damage(10) in that script before this function returns.

The target is either a single script attachment, returning that callback’s value, or [Recipients], returning a list with the value of each script which ran the callback. Errors of the callbacks are raised in the calling script, for recipients only after all of them ran.

Callbacks cannot run immediately in a script whose context is busy, i.e. the calling script itself, scripts sharing its context (depending on the context policy), or scripts further up the current chain of callbacks. Use queue_script_callback for those. It is also unavailable in script systems running in parallel with other systems.

Arguments

NameTypeDocumentation
labelStringThe name of the callback to run.
targetScriptAttachmentRecipients
argsThe arguments to pass to the callback.

Returns

NameTypeDocumentation
resultScriptValueThe value returned by the callback, or a list of the values returned by each recipient.

system_builder

Creates a new script system builder, which can be used to add new systems to the world.

Arguments

NameTypeDocumentation
callbackStringThe function name in the script this system should call when run.
attachmentScriptAttachmentThe script attachment to use for the system. This is the attachment that will be used for the system’s callback.

Returns

NameTypeDocumentation
builderScriptSystemBuilderThe system builder

unpack_args

Unpacks, a list of values, into many separate values.

Arguments

NameTypeDocumentation
valuesVec<ScriptValue>The list of values to uncurry

Returns

NameTypeDocumentation
tupleThe tuple of all values provided

camera

The types and functions in the camera namespace, as returned by import_namespace("camera").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
CameraThe defining [`Component`] for camera entities, storing information about how and what to render through this camera. The [`Camera`]...
OrthographicProjectionProject a 3D space onto a 2D surface using parallel lines, i.e., unlike [`PerspectiveProjection`], the size of objects remains the same regardless of their distance to the camera. The volume contained in the projection is called the *view frustum*. Since the viewport is rectangular and projection lines are parallel, the view frustum takes the shape of a cuboid. Note that the scale of the projection and the apparent size of objects are inversely proportional. As the size of the projection increases, the size of objects decreases. # Examples Configure the orthographic projection to one world unit per 100 window pixels: ``` # use bevy_camera::{OrthographicProjection, Projection, ScalingMode}; let projection = Projection::Orthographic(OrthographicProjection { scaling_mode: ScalingMode::WindowSize, scale: 0.01, ..OrthographicProjection::default_2d() }); ```
InheritedVisibilityWhether or not an entity is visible in the hierarchy. This is a computed component that users sho...
ViewVisibilityAlgorithmically computed indication of whether an entity is visible and should be extracted for re...
VisibilityUser indication of whether an entity is visible. Propagates down the entity hierarchy. If an enti...
RenderLayersDefines which rendering layers an entity belongs to. A camera renders an entity only when their r...
CameraOutputModeControl how this [`Camera`] outputs once rendering is completed.
ComputedCameraValuesHolds internally computed [`Camera`] values.
ImageRenderTargetA render target that renders to an [`Image`].
ManualTextureViewHandleA unique id that corresponds to a specific `ManualTextureView` in the `ManualTextureViews` collecti...
RenderTargetThe “target” that a [`Camera`] will render to. For example, this could be a `Window` swapchain or an [`Image`]...
RenderTargetInfoInformation about the current [`RenderTarget`].
SubCameraViewSettings to define a camera sub view. When [`Camera::sub_camera_view`] is `Some`, only the sub-section of the image defined by `size` and `offset` (relative to the `full_size` of the whole image) is projected to the cameras viewport. Take the example of the following multi-monitor setup: ```css ┌───┬───┐ │ A │ B │ ├───┼───┤ │ C │ D │ └───┴───┘ ``` If each monitor is 1920x1080, the whole image will have a resolution of 3840x2160. For each monitor we can use a single camera with a viewport of the same size as the monitor it corresponds to. To ensure that the image is cohesive, we can use a different sub view on each camera: - Camera A: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 0,0 - Camera B: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 1920,0 - Camera C: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 0,1080 - Camera D: `full_size` = 3840x2160, `size` = 1920x1080, `offset` = 1920,1080 However since only the ratio between the values is important, they could all be divided by 120 and still produce the same image. Camera D would for example have the following values: `full_size` = 32x18, `size` = 16x9, `offset` = 16,9
ViewportRender viewport configuration for the [`Camera`] component. The viewport defines the area on the render target to which the camera renders its image. You can overlay multiple cameras in a single window using viewports to create effects like split screen, minimaps, and character viewers.
Note that the physical position is in actual screen coordinates and not virtual pixels for window targets. You should use the scaling factor reported by the window, which on some OS’s defaults to a value other than 1. Please see the example code (which assumes a single camera and window) ```no_run # use bevy_camera::{Camera, Projection, Viewport}; # use bevy_transform::prelude::Transform; # use bevy_ecs::prelude::*; # use bevy_math::UVec2; # use bevy_window::Window; # use bevy_utils::default; fn update_viewport( mut camera_query: Query<(&mut Camera, &mut Transform, &mut Projection)>, windows: Query<&Window> ) { let Ok((mut camera, _, _)) = camera_query.single_mut() else { return; }; let window = windows.single().expect(“Window not found”); let scale = window.resolution.scale_factor(); camera.viewport = Some(Viewport { physical_position: (UVec2::new(10, 10).as_vec2() * scale).as_uvec2(), physical_size: (UVec2::new(100, 100).as_vec2() * scale).as_uvec2(), ..default() }); } ```
ClearColorConfigFor a camera, specifies the color used to clear the viewport [before rendering](crate::camera::Camera::clear_color) or when [writing to the final render target texture](crate::camera::Camera::output_mode)...
MsaaWritebackControls when MSAA writeback occurs for a camera. MSAA writeback copies the previous camera’s out...
ScalingModeScaling mode for [`OrthographicProjection`]. The effect of these scaling modes are combined with the [`OrthographicProjection::scale`]...

Values

NameType
CameraUpdateSystemsReflectSystemSet

Camera

Camera

Description

The defining [Component] for camera entities, storing information about how and what to render through this camera.

The [Camera] component is added to an entity to define the properties of the viewpoint from which rendering occurs. It defines the position of the view to render, the projection method to transform the 3D objects into a 2D image, as well as the render target into which that image is produced.

Note that a [Camera] needs a CameraRenderGraph to render anything. This is typically provided by adding a Camera2d or Camera3d component, but custom render graphs can also be defined. Inserting a [Camera] with no render graph will emit an error at runtime.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
viewport_to_world_2dThe point in the 2D world seen through a point on the viewport, or nil if the point cannot be conver...
physical_viewport_sizeThe size of the viewport in physical pixels, or nil if the camera has no target yet.
logical_viewport_sizeThe size of the viewport in logical pixels, or nil if the camera has no target yet.
world_to_viewportThe position on the viewport of a point in the world, or nil if the point cannot be converted.
logical_viewport_rectThe rectangle of the viewport in logical pixels, or nil if the camera has no target yet.
viewport_to_worldA ray from the camera through a point on its viewport, or nil if the point cannot be converted.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

viewport_to_world_2d

The point in the 2D world seen through a point on the viewport, or nil if the point cannot be converted.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧
camera_transformGlobalTransformNo Documentation 🚧
viewport_positionVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec2>No Documentation 🚧

physical_viewport_size

The size of the viewport in physical pixels, or nil if the camera has no target yet.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<UVec2>No Documentation 🚧

logical_viewport_size

The size of the viewport in logical pixels, or nil if the camera has no target yet.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec2>No Documentation 🚧

world_to_viewport

The position on the viewport of a point in the world, or nil if the point cannot be converted.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧
camera_transformGlobalTransformNo Documentation 🚧
world_positionVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec2>No Documentation 🚧

logical_viewport_rect

The rectangle of the viewport in logical pixels, or nil if the camera has no target yet.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Rect>No Documentation 🚧

viewport_to_world

A ray from the camera through a point on its viewport, or nil if the point cannot be converted.

Arguments

NameTypeDocumentation
_selfCameraNo Documentation 🚧
camera_transformGlobalTransformNo Documentation 🚧
viewport_positionVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Ray3d>No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Camera>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCameraThe constructed value.

OrthographicProjection

OrthographicProjection

Description

Project a 3D space onto a 2D surface using parallel lines, i.e., unlike [PerspectiveProjection], the size of objects remains the same regardless of their distance to the camera.

The volume contained in the projection is called the view frustum. Since the viewport is rectangular and projection lines are parallel, the view frustum takes the shape of a cuboid.

Note that the scale of the projection and the apparent size of objects are inversely proportional. As the size of the projection increases, the size of objects decreases.

Examples

Configure the orthographic projection to one world unit per 100 window pixels:

# use bevy_camera::{OrthographicProjection, Projection, ScalingMode};
let projection = Projection::Orthographic(OrthographicProjection {
    scaling_mode: ScalingMode::WindowSize,
    scale: 0.01,
    ..OrthographicProjection::default_2d()
});

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
default_2dThe default projection for 2D cameras.
default_3dThe default projection for 3D cameras.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

default_2d

The default projection for 2D cameras.

Arguments

Returns

NameTypeDocumentation
returnOrthographicProjectionNo Documentation 🚧

default_3d

The default projection for 3D cameras.

Arguments

Returns

NameTypeDocumentation
returnOrthographicProjectionNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<OrthographicProjection>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOrthographicProjectionThe constructed value.

InheritedVisibility

InheritedVisibility

  1. Bool

Description

Whether or not an entity is visible in the hierarchy.

This is a computed component that users should not change manually. To set the visibility of an entity, use [Visibility] instead. For more information, see module level documentation.

This property is updated in VisibilityPropagate in the [PostUpdate] schedule. Until then, it is not up to date with [Visibility] if it was changed in the same frame.

If this is false, then [ViewVisibility] should also be false.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
getWhether the entity is visible, taking its parents into account.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

get

Whether the entity is visible, taking its parents into account.

Arguments

NameTypeDocumentation
_selfInheritedVisibilityNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InheritedVisibility>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInheritedVisibilityThe constructed value.

ViewVisibility

ViewVisibility

  1. U8

Description

Algorithmically computed indication of whether an entity is visible and should be extracted for rendering.

Not to be confused with [Visibility] and [InheritedVisibility]. For more information, see module level documentation.

If you wish to add a custom visibility system that sets this value, be sure to add it to the CheckVisibility set.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
getWhether the entity is visible to a camera this frame.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

get

Whether the entity is visible to a camera this frame.

Arguments

NameTypeDocumentation
_selfViewVisibilityNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ViewVisibility>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceViewVisibilityThe constructed value.

Visibility

Inherited

Hidden

Visible

Description

User indication of whether an entity is visible. Propagates down the entity hierarchy.

If an entity is hidden in this way, all [Children] (and all of their children and so on) who are set to Inherited will also be hidden.

Users should set this component if they wish to change the visibility of an entity.

To read the visibility of an entity, query for its [InheritedVisibility] instead. For more information, see module level documentation.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
toggle_visible_hiddenSwitches between visible and hidden. An inherited entity stays inherited.
toggle_inherited_visibleSwitches between inherited and visible. A hidden entity stays hidden.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Hidden.newNo Documentation 🚧
Inherited.newNo Documentation 🚧
Visible.newNo Documentation 🚧

toggle_visible_hidden

Switches between visible and hidden. An inherited entity stays inherited.

Arguments

NameTypeDocumentation
_selfVisibilityNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

toggle_inherited_visible

Switches between inherited and visible. A hidden entity stays hidden.

Arguments

NameTypeDocumentation
_selfVisibilityNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Visibility>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVisibilityThe constructed value.

Hidden.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Visibility::Hidden>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisibilityNo Documentation 🚧

Inherited.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Visibility::Inherited>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisibilityNo Documentation 🚧

Visible.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Visibility::Visible>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisibilityNo Documentation 🚧

RenderLayers

RenderLayers

  1. Vec<U64>

Description

Defines which rendering layers an entity belongs to.

A camera renders an entity only when their render layers intersect.

The [Default] instance of RenderLayers contains layer 0, the first layer. Entities without this component also belong to layer 0.

An empty RenderLayers makes the entity invisible.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
layerRender layers containing only the given layer.
withA copy of these render layers that also contains the given layer.
withoutA copy of these render layers without the given layer.
intersectsWhether these render layers share at least one layer with another set.
noneRender layers containing no layers, so nothing is rendered with them.
iterThe numbers of all layers in these render layers.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

layer

Render layers containing only the given layer.

Arguments

NameTypeDocumentation
nUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnRenderLayersNo Documentation 🚧

with

A copy of these render layers that also contains the given layer.

Arguments

NameTypeDocumentation
_selfRenderLayersNo Documentation 🚧
nUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnRenderLayersNo Documentation 🚧

without

A copy of these render layers without the given layer.

Arguments

NameTypeDocumentation
_selfRenderLayersNo Documentation 🚧
nUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnRenderLayersNo Documentation 🚧

intersects

Whether these render layers share at least one layer with another set.

Arguments

NameTypeDocumentation
_selfRenderLayersNo Documentation 🚧
otherRenderLayersNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

none

Render layers containing no layers, so nothing is rendered with them.

Arguments

Returns

NameTypeDocumentation
returnRenderLayersNo Documentation 🚧

iter

The numbers of all layers in these render layers.

Arguments

NameTypeDocumentation
_selfRenderLayersNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec<Usize>No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RenderLayers>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRenderLayersThe constructed value.

CameraOutputMode

Write

Skip

Description

Control how this [Camera] outputs once rendering is completed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Skip.newNo Documentation 🚧
Write.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<CameraOutputMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCameraOutputModeThe constructed value.

Skip.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CameraOutputMode::Skip>No Documentation 🚧

Returns

NameTypeDocumentation
returnCameraOutputModeNo Documentation 🚧

Write.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CameraOutputMode::Write>No Documentation 🚧

Returns

NameTypeDocumentation
returnCameraOutputModeNo Documentation 🚧

ComputedCameraValues

ComputedCameraValues

Description

Holds internally computed [Camera] values.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ComputedCameraValues>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceComputedCameraValuesThe constructed value.

ImageRenderTarget

ImageRenderTarget

Description

A render target that renders to an [Image].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ImageRenderTarget>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceImageRenderTargetThe constructed value.

ManualTextureViewHandle

ManualTextureViewHandle

  1. U32

Description

A unique id that corresponds to a specific ManualTextureView in the ManualTextureViews collection.

See ManualTextureViews in bevy_camera for more details.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ManualTextureViewHandle>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceManualTextureViewHandleThe constructed value.

RenderTarget

Window

  1. WindowRef

Image

  1. ImageRenderTarget

TextureView

  1. ManualTextureViewHandle

None

Description

The “target” that a [Camera] will render to. For example, this could be a Window swapchain or an [Image].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Image.newNo Documentation 🚧
None.newNo Documentation 🚧
TextureView.newNo Documentation 🚧
Window.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RenderTarget>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRenderTargetThe constructed value.

Image.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RenderTarget::Image>No Documentation 🚧

Returns

NameTypeDocumentation
returnRenderTargetNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RenderTarget::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnRenderTargetNo Documentation 🚧

TextureView.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RenderTarget::TextureView>No Documentation 🚧

Returns

NameTypeDocumentation
returnRenderTargetNo Documentation 🚧

Window.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<RenderTarget::Window>No Documentation 🚧

Returns

NameTypeDocumentation
returnRenderTargetNo Documentation 🚧

RenderTargetInfo

RenderTargetInfo

Description

Information about the current [RenderTarget].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RenderTargetInfo>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRenderTargetInfoThe constructed value.

SubCameraView

SubCameraView

Description

Settings to define a camera sub view.

When [Camera::sub_camera_view] is Some, only the sub-section of the image defined by size and offset (relative to the full_size of the whole image) is projected to the cameras viewport.

Take the example of the following multi-monitor setup:

┌───┬───┐
│ A │ B │
├───┼───┤
│ C │ D │
└───┴───┘

If each monitor is 1920x1080, the whole image will have a resolution of 3840x2160. For each monitor we can use a single camera with a viewport of the same size as the monitor it corresponds to. To ensure that the image is cohesive, we can use a different sub view on each camera:

  • Camera A: full_size = 3840x2160, size = 1920x1080, offset = 0,0
  • Camera B: full_size = 3840x2160, size = 1920x1080, offset = 1920,0
  • Camera C: full_size = 3840x2160, size = 1920x1080, offset = 0,1080
  • Camera D: full_size = 3840x2160, size = 1920x1080, offset = 1920,1080

However since only the ratio between the values is important, they could all be divided by 120 and still produce the same image. Camera D would for example have the following values: full_size = 32x18, size = 16x9, offset = 16,9

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SubCameraView>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSubCameraViewThe constructed value.

Viewport

Viewport

Description

Render viewport configuration for the [Camera] component.

The viewport defines the area on the render target to which the camera renders its image. You can overlay multiple cameras in a single window using viewports to create effects like split screen, minimaps, and character viewers.

Note that the physical position is in actual screen coordinates and not virtual pixels for window targets.
You should use the scaling factor reported by the window, which on some OS’s defaults to a value other than 1. Please see the example code (which assumes a single camera and window)

# use bevy_camera::{Camera, Projection, Viewport};
# use bevy_transform::prelude::Transform;
# use bevy_ecs::prelude::*;
# use bevy_math::UVec2;
# use bevy_window::Window;
# use bevy_utils::default;

fn update_viewport(
   mut camera_query: Query<(&mut Camera, &mut Transform, &mut Projection)>,
   windows: Query<&Window>
) {
    let Ok((mut camera, _, _)) = camera_query.single_mut() else { return; };

    let window = windows.single().expect("Window not found");
    let scale = window.resolution.scale_factor();

    camera.viewport = Some(Viewport {
        physical_position: (UVec2::new(10, 10).as_vec2() * scale).as_uvec2(),
        physical_size: (UVec2::new(100, 100).as_vec2() * scale).as_uvec2(),
        ..default()
    });
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Viewport>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceViewportThe constructed value.

ClearColorConfig

Default

Custom

  1. Color

None

Description

For a camera, specifies the color used to clear the viewport before rendering or when writing to the final render target texture.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Custom.newNo Documentation 🚧
Default.newNo Documentation 🚧
None.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ClearColorConfig>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceClearColorConfigThe constructed value.

Custom.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ClearColorConfig::Custom>No Documentation 🚧

Returns

NameTypeDocumentation
returnClearColorConfigNo Documentation 🚧

Default.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ClearColorConfig::Default>No Documentation 🚧

Returns

NameTypeDocumentation
returnClearColorConfigNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ClearColorConfig::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnClearColorConfigNo Documentation 🚧

MsaaWriteback

Off

Auto

Always

Description

Controls when MSAA writeback occurs for a camera.

MSAA writeback copies the previous camera’s output into the MSAA sampled texture before rendering, allowing multiple cameras to layer their results when MSAA is enabled.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Always.newNo Documentation 🚧
Auto.newNo Documentation 🚧
Off.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MsaaWriteback>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMsaaWritebackThe constructed value.

Always.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MsaaWriteback::Always>No Documentation 🚧

Returns

NameTypeDocumentation
returnMsaaWritebackNo Documentation 🚧

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MsaaWriteback::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnMsaaWritebackNo Documentation 🚧

Off.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MsaaWriteback::Off>No Documentation 🚧

Returns

NameTypeDocumentation
returnMsaaWritebackNo Documentation 🚧

ScalingMode

WindowSize

Fixed

AutoMin

  • min_width:F32
  • min_height:F32

AutoMax

  • max_width:F32
  • max_height:F32

FixedVertical

  • viewport_height:F32

FixedHorizontal

  • viewport_width:F32

Description

Scaling mode for [OrthographicProjection].

The effect of these scaling modes are combined with the [OrthographicProjection::scale] property.

For example, if the scaling mode is ScalingMode::Fixed { width: 100.0, height: 300 } and the scale is 2.0, the projection will be 200 world units wide and 600 world units tall.

Examples

Configure the orthographic projection to two world units per window height:

# use bevy_camera::{OrthographicProjection, Projection, ScalingMode};
let projection = Projection::Orthographic(OrthographicProjection {
   scaling_mode: ScalingMode::FixedVertical { viewport_height: 2.0 },
   ..OrthographicProjection::default_2d()
});

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AutoMax.newNo Documentation 🚧
AutoMin.newNo Documentation 🚧
Fixed.newNo Documentation 🚧
FixedHorizontal.newNo Documentation 🚧
FixedVertical.newNo Documentation 🚧
WindowSize.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScalingMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScalingModeThe constructed value.

AutoMax.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::AutoMax>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

AutoMin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::AutoMin>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

Fixed.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

FixedHorizontal.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::FixedHorizontal>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

FixedVertical.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::FixedVertical>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

WindowSize.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScalingMode::WindowSize>No Documentation 🚧

Returns

NameTypeDocumentation
returnScalingModeNo Documentation 🚧

camera.VisibilitySystems

The types and functions in the camera.VisibilitySystems namespace, as returned by import_namespace("camera.VisibilitySystems").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

Values

NameType
CalculateBoundsReflectSystemSet
CheckVisibilityReflectSystemSet
MarkNewlyHiddenEntitiesInvisibleReflectSystemSet
UpdateFrustaReflectSystemSet
VisibilityPropagateReflectSystemSet

color

The types and functions in the color namespace, as returned by import_namespace("color").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
ColorAn enumerated type that can represent any of the color types in this crate. This is useful when y...
HslaColor in Hue-Saturation-Lightness (HSL) color space with alpha. Further information on this color ...
HsvaColor in Hue-Saturation-Value (HSV) color space with alpha. Further information on this color mode...
HwbaColor in Hue-Whiteness-Blackness (HWB) color space with alpha. Further information on this color m...
LabaColor in LAB color space, with alpha
LchaColor in LCH color space, with alpha
LinearRgbaLinear RGB color with alpha. SDR colors are in `[0.0, 1.0]`. Values above `1.0` are HDR intensities.
OklabaColor in Oklab color space, with alpha
OklchaColor in Oklch color space, with alpha
SrgbaNon-linear standard RGB with alpha. SDR colors are in `[0.0, 1.0]`. Values above `1.0` are HDR intensities.
Xyza[CIE 1931](https://en.wikipedia.org/wiki/CIE_1931_color_space) color space, also known as XYZ, with an alpha channel. The SDR channel bounds below are the D65 white point, `(0.9505, 1.0, 1.0889)`.
OkhslaColor in Okhsl color space with alpha. Further information on this color model can be found on <ht...
OkhsvaColor in Okhsv color space with alpha. Further information on this color model can be found on <ht...
OkhwbaColor in Okhwb color space with alpha. Further information on this color model can be found on <ht...

Color

Srgba

  1. Srgba

LinearRgba

  1. LinearRgba

Hsla

  1. Hsla

Hsva

  1. Hsva

Hwba

  1. Hwba

Laba

  1. Laba

Lcha

  1. Lcha

Oklaba

  1. Oklaba

Oklcha

  1. Oklcha

Xyza

  1. Xyza

Okhsla

  1. Okhsla

Okhsva

  1. Okhsva

Okhwba

  1. Okhwba

Description

An enumerated type that can represent any of the color types in this crate.

This is useful when you need to store a color in a data structure that can’t be generic over the color type.

Operations

[Color] supports all the standard color operations, such as mixing, luminance and hue adjustment, and diffing. These operations delegate to the concrete color space contained by [Color], but will convert to Oklch for operations which aren’t supported in the current space. After performing the operation, if a conversion was required, the result will be converted back into the original color space.

#![allow(unused)]
fn main() {
use bevy_color::{Hue, Color};
let red_hsv = Color::hsv(0., 1., 1.);
let red_srgb = Color::srgb(1., 0., 0.);

// HSV has a definition of hue, so it will be returned.
red_hsv.hue();

// SRGB doesn't have a native definition for hue.
// Converts to Oklch and returns that result.
red_srgb.hue();
}

Oklch has been chosen as the intermediary space in cases where conversion is required due to its perceptual uniformity and broad support for Bevy’s color operations. To avoid the cost of repeated conversion, and ensure consistent results where that is desired, first convert this [Color] into your desired color space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
hsvA color from hue (in degrees), saturation and value, fully opaque.
srgba_u8A color from red, green, blue and alpha in the sRGB space, each from `0` to `255`.
is_fully_transparentWhether the color is completely transparent.
hslaA color from hue (in degrees), saturation, lightness and alpha.
to_hexThe color as an uppercase hex string such as `“#FF8800”`, with alpha appended unless fully opaque.
namedA named CSS color such as `“rebecca_purple”` (case-insensitive), or nil if there is no color with that name.
to_linearThe color converted to the linear RGB space.
set_alphaSets the alpha (opacity) of the color in place.
with_alphaA copy of the color with its alpha set to `alpha`.
hsvaA color from hue (in degrees), saturation, value and alpha.
darkerA darker copy of the color, `amount` from `0` to `1`.
linear_rgbA color from red, green and blue in the linear RGB space, each from `0` to `1`, fully opaque.
luminanceThe perceived brightness of the color, from `0` (black) to `1` (white).
linear_rgbaA color from red, green, blue and alpha in the linear RGB space, each from `0` to `1`.
noneA fully transparent color.
srgb_u8A color from red, green and blue in the sRGB space, each from `0` to `255`, fully opaque.
to_srgbaThe color converted to the sRGB space.
mixA color between this one and `other`, `t = 0` gives this color and `t = 1` gives `other`.
eqWhether both colors are the same color in the same color space.
srgbA color from red, green and blue in the sRGB space, each from `0` to `1`, fully opaque. ```multi-lang-example,lua local Color = import_namespace(“color”).Color local red = Color.srgb(1.0, 0.0, 0.0) assert(red:to_srgba().red == 1.0) `...
blackOpaque black.
whiteOpaque white.
hslA color from hue (in degrees), saturation and lightness, fully opaque.
hexA color from a hex string such as `“#ff8800”` or `“#ff880080”`, or an error if the string is not val...
srgbaA color from red, green, blue and alpha in the sRGB space, each from `0` to `1`.
alphaThe alpha (opacity) of the color, from `0` (transparent) to `1` (opaque).
lighterA lighter copy of the color, `amount` from `0` to `1`.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Hsla.newNo Documentation 🚧
Hsva.newNo Documentation 🚧
Hwba.newNo Documentation 🚧
Laba.newNo Documentation 🚧
Lcha.newNo Documentation 🚧
LinearRgba.newNo Documentation 🚧
Okhsla.newNo Documentation 🚧
Okhsva.newNo Documentation 🚧
Okhwba.newNo Documentation 🚧
Oklaba.newNo Documentation 🚧
Oklcha.newNo Documentation 🚧
Srgba.newNo Documentation 🚧
Xyza.newNo Documentation 🚧

hsv

A color from hue (in degrees), saturation and value, fully opaque.

Arguments

NameTypeDocumentation
hueF32No Documentation 🚧
saturationF32No Documentation 🚧
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

srgba_u8

A color from red, green, blue and alpha in the sRGB space, each from 0 to 255.

Arguments

NameTypeDocumentation
redU8No Documentation 🚧
greenU8No Documentation 🚧
blueU8No Documentation 🚧
alphaU8No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

is_fully_transparent

Whether the color is completely transparent.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

hsla

A color from hue (in degrees), saturation, lightness and alpha.

Arguments

NameTypeDocumentation
hueF32No Documentation 🚧
saturationF32No Documentation 🚧
lightnessF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

to_hex

The color as an uppercase hex string such as "#FF8800", with alpha appended unless fully opaque.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

named

A named CSS color such as "rebecca_purple" (case-insensitive), or nil if there is no color with that name.

Arguments

NameTypeDocumentation
nameStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Color>No Documentation 🚧

to_linear

The color converted to the linear RGB space.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnLinearRgbaNo Documentation 🚧

set_alpha

Sets the alpha (opacity) of the color in place.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

with_alpha

A copy of the color with its alpha set to alpha.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

hsva

A color from hue (in degrees), saturation, value and alpha.

Arguments

NameTypeDocumentation
hueF32No Documentation 🚧
saturationF32No Documentation 🚧
valueF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

darker

A darker copy of the color, amount from 0 to 1.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
amountF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

linear_rgb

A color from red, green and blue in the linear RGB space, each from 0 to 1, fully opaque.

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

luminance

The perceived brightness of the color, from 0 (black) to 1 (white).

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

linear_rgba

A color from red, green, blue and alpha in the linear RGB space, each from 0 to 1.

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

none

A fully transparent color.

Arguments

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

srgb_u8

A color from red, green and blue in the sRGB space, each from 0 to 255, fully opaque.

Arguments

NameTypeDocumentation
redU8No Documentation 🚧
greenU8No Documentation 🚧
blueU8No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

to_srgba

The color converted to the sRGB space.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnSrgbaNo Documentation 🚧

mix

A color between this one and other, t = 0 gives this color and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
otherColorNo Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

eq

Whether both colors are the same color in the same color space.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
otherColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

srgb

A color from red, green and blue in the sRGB space, each from 0 to 1, fully opaque.

local Color = import_namespace("color").Color
local red = Color.srgb(1.0, 0.0, 0.0)
assert(red:to_srgba().red == 1.0)
let Color = import_namespace("color").Color;
let red = Color.srgb(1.0, 0.0, 0.0);
assert!(red.to_srgba().red == 1.0);

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

black

Opaque black.

Arguments

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

white

Opaque white.

Arguments

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

hsl

A color from hue (in degrees), saturation and lightness, fully opaque.

Arguments

NameTypeDocumentation
hueF32No Documentation 🚧
saturationF32No Documentation 🚧
lightnessF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

hex

A color from a hex string such as "#ff8800" or "#ff880080", or an error if the string is not valid hex.

Arguments

NameTypeDocumentation
hexStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

srgba

A color from red, green, blue and alpha in the sRGB space, each from 0 to 1.

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

alpha

The alpha (opacity) of the color, from 0 (transparent) to 1 (opaque).

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

lighter

A lighter copy of the color, amount from 0 to 1.

Arguments

NameTypeDocumentation
_selfColorNo Documentation 🚧
amountF32No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Color>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceColorThe constructed value.

Hsla.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Hsla>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Hsva.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Hsva>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Hwba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Hwba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Laba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Laba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Lcha.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Lcha>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

LinearRgba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::LinearRgba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Okhsla.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Okhsla>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Okhsva.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Okhsva>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Okhwba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Okhwba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Oklaba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Oklaba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Oklcha.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Oklcha>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Srgba.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Srgba>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Xyza.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Color::Xyza>No Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Hsla

Hsla

Description

Color in Hue-Saturation-Lightness (HSL) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.
newreates a color from hue (degrees), saturation, lightness and alpha.

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfHslaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

reates a color from hue (degrees), saturation, lightness and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnHslaNo Documentation 🚧

Hsva

Hsva

Description

Color in Hue-Saturation-Value (HSV) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newreates a color from hue (degrees), saturation, value and alpha.
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.

new

reates a color from hue (degrees), saturation, value and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnHsvaNo Documentation 🚧

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfHsvaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Hwba

Hwba

Description

Color in Hue-Whiteness-Blackness (HWB) color space with alpha. Further information on this color model can be found on Wikipedia.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newreates a color from hue (degrees), whiteness, blackness and alpha.
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.

new

reates a color from hue (degrees), whiteness, blackness and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnHwbaNo Documentation 🚧

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfHwbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Laba

Laba

Description

Color in LAB color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newreates a color from lightness, a, b and alpha.
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.

new

reates a color from lightness, a, b and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnLabaNo Documentation 🚧

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfLabaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Lcha

Lcha

Description

Color in LCH color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.
newreates a color from lightness, chroma, hue (degrees) and alpha.

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfLchaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

reates a color from lightness, chroma, hue (degrees) and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnLchaNo Documentation 🚧

LinearRgba

LinearRgba

Description

Linear RGB color with alpha.

SDR colors are in [0.0, 1.0]. Values above 1.0 are HDR intensities.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color).
newA color from linear red, green, blue and alpha, each from `0` to `1`. ```multi-lang-example,lua local LinearRgba = import_namespace(“color”).LinearRgba local c = LinearRgba.new(1.0, 0.0, 0.0, 1.0) assert(c.red == 1.0) ``` ```multi-lang-example,rune let LinearRgba = import_...
rgbA fully opaque color from linear red, green and blue, each from `0` to `1`.
eqWhether both colors have the same red, green, blue and alpha.
mulA copy with red, green and blue multiplied by `factor`, keeping alpha. Useful for making emissive co...

to_color

The color as a Color.

Arguments

NameTypeDocumentation
_selfLinearRgbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

A color from linear red, green, blue and alpha, each from 0 to 1.

local LinearRgba = import_namespace("color").LinearRgba
local c = LinearRgba.new(1.0, 0.0, 0.0, 1.0)
assert(c.red == 1.0)
let LinearRgba = import_namespace("color").LinearRgba;
let c = LinearRgba.new(1.0, 0.0, 0.0, 1.0);
assert!(c.red == 1.0);

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnLinearRgbaNo Documentation 🚧

rgb

A fully opaque color from linear red, green and blue, each from 0 to 1.

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnLinearRgbaNo Documentation 🚧

eq

Whether both colors have the same red, green, blue and alpha.

Arguments

NameTypeDocumentation
_selfLinearRgbaNo Documentation 🚧
otherLinearRgbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

mul

A copy with red, green and blue multiplied by factor, keeping alpha. Useful for making emissive colors brighter.

Arguments

NameTypeDocumentation
_selfLinearRgbaNo Documentation 🚧
factorF32No Documentation 🚧

Returns

NameTypeDocumentation
returnLinearRgbaNo Documentation 🚧

Oklaba

Oklaba

Description

Color in Oklab color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newreates a color from lightness, a, b and alpha.
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.

new

reates a color from lightness, a, b and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnOklabaNo Documentation 🚧

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfOklabaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

Oklcha

Oklcha

Description

Color in Oklch color space, with alpha

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.
newreates a color from lightness, chroma, hue (degrees) and alpha.

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfOklchaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

reates a color from lightness, chroma, hue (degrees) and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnOklchaNo Documentation 🚧

Srgba

Srgba

Description

Non-linear standard RGB with alpha.

SDR colors are in [0.0, 1.0]. Values above 1.0 are HDR intensities.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color).
hexA color from a hex string such as `“#ff8800”` or `“#ff880080”`, or an error if the string is not val...
with_alphaA copy of the color with its alpha set to `alpha`.
eqWhether both colors have the same red, green, blue and alpha.
to_hexThe color as an uppercase hex string such as `“#FF8800”`, with alpha appended unless fully opaque.
rgbA fully opaque color from red, green and blue, each from `0` to `1`.
newA color from red, green, blue and alpha, each from `0` to `1`. ```multi-lang-example,lua local Srgba = import_namespace(“color”).Srgba local c = Srgba.new(1.0, 0.0, 0.0, 0.5) assert(c.alpha == 0.5) ``` ```multi-lang-example,rune let Srgba = import_...

to_color

The color as a Color.

Arguments

NameTypeDocumentation
_selfSrgbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

hex

A color from a hex string such as "#ff8800" or "#ff880080", or an error if the string is not valid hex.

Arguments

NameTypeDocumentation
hexStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnSrgbaNo Documentation 🚧

with_alpha

A copy of the color with its alpha set to alpha.

Arguments

NameTypeDocumentation
_selfSrgbaNo Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnSrgbaNo Documentation 🚧

eq

Whether both colors have the same red, green, blue and alpha.

Arguments

NameTypeDocumentation
_selfSrgbaNo Documentation 🚧
otherSrgbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

to_hex

The color as an uppercase hex string such as "#FF8800", with alpha appended unless fully opaque.

Arguments

NameTypeDocumentation
_selfSrgbaNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

rgb

A fully opaque color from red, green and blue, each from 0 to 1.

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnSrgbaNo Documentation 🚧

new

A color from red, green, blue and alpha, each from 0 to 1.

local Srgba = import_namespace("color").Srgba
local c = Srgba.new(1.0, 0.0, 0.0, 0.5)
assert(c.alpha == 0.5)
let Srgba = import_namespace("color").Srgba;
let c = Srgba.new(1.0, 0.0, 0.0, 0.5);
assert!(c.alpha == 0.5);

Arguments

NameTypeDocumentation
redF32No Documentation 🚧
greenF32No Documentation 🚧
blueF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnSrgbaNo Documentation 🚧

Xyza

Xyza

Description

CIE 1931 color space, also known as XYZ, with an alpha channel.

The SDR channel bounds below are the D65 white point, (0.9505, 1.0, 1.0889).

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_colorThe color as a [`Color`](bevy_color::Color), in the same color space.
newreates a color from x, y, z and alpha.

to_color

The color as a Color, in the same color space.

Arguments

NameTypeDocumentation
_selfXyzaNo Documentation 🚧

Returns

NameTypeDocumentation
returnColorNo Documentation 🚧

new

reates a color from x, y, z and alpha.

Arguments

NameTypeDocumentation
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧
alphaF32No Documentation 🚧

Returns

NameTypeDocumentation
returnXyzaNo Documentation 🚧

Okhsla

Okhsla

Description

Color in Okhsl color space with alpha. Further information on this color model can be found on https://bottosson.github.io/posts/colorpicker.

Okhsl is defined relative to the sRGB (Rec. 709) gamut. Converting a wide-gamut or HDR color clamps the lightness to 1.0 but can push saturation outside [0.0, 1.0].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Okhsla>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOkhslaThe constructed value.

Okhsva

Okhsva

Description

Color in Okhsv color space with alpha. Further information on this color model can be found on https://bottosson.github.io/posts/colorpicker.

Okhsv is defined relative to the sRGB (Rec. 709) gamut. Converting a wide-gamut or HDR color can push saturation and value outside [0.0, 1.0].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Okhsva>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOkhsvaThe constructed value.

Okhwba

Okhwba

Description

Color in Okhwb color space with alpha. Further information on this color model can be found on https://bottosson.github.io/posts/colorpicker.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Okhwba>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOkhwbaThe constructed value.

core

The types and functions in the core namespace, as returned by import_namespace("core").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
TypeIdNo Documentation 🚧
NonZeroI16No Documentation 🚧
NonZeroU16No Documentation 🚧
NonZeroU32No Documentation 🚧
Range<F32>No Documentation 🚧

TypeId

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TypeId>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTypeIdThe constructed value.

NonZeroI16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NonZeroI16>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNonZeroI16The constructed value.

NonZeroU16

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NonZeroU16>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNonZeroU16The constructed value.

NonZeroU32

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NonZeroU32>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNonZeroU32The constructed value.

Range<F32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Range<F32>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRange<F32>The constructed value.

ecs

The types and functions in the ecs namespace, as returned by import_namespace("ecs").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
EntityUnique identifier for an entity in a [`World`]. Note that this is just an id, not the entity itself. Further, the entity this id refers to may no longer exist in the [`World`]...
ChildOfStores the parent entity of this child entity with this component. This is a [`Relationship`] component, and creates the canonical “parent / child” hierarchy. This is the “source of truth” component, and it pairs with the [`Children`]...
NameComponent used to identify an entity. Stores a hash for faster comparisons. The hash is eagerly r...
ComponentIdA value which uniquely identifies the type of a [`Component`] or [`Resource`](crate::resource::Reso...
AddEventTrigger emitted when a component is inserted onto an entity that does not already have that compon...
DespawnEvent[`EntityEvent`] emitted for each component on an entity when it is despawned. See [`ComponentHooks::on_despawn`](`crate::lifecycle::ComponentHooks::on_...
DiscardEventTrigger emitted when a component is removed from an entity, regardless of whether or not it is lat...
InsertEventTrigger emitted when a component is inserted, regardless of whether or not the entity already had ...
RemoveEventTrigger emitted when a component is removed from an entity, and runs before the component is remov...
HashedStrA wrapper over Hashed. This exists to make Name(“value”.into()) possible, which plays nicely with c...

Entity

Opaque Type. 🔒

Description

Unique identifier for an entity in a World. Note that this is just an id, not the entity itself. Further, the entity this id refers to may no longer exist in the World. For more information about entities, their ids, and how to use them, see the module docs.

Aliasing

Once an entity is despawned, it ceases to exist. However, its [Entity] id is still present, and may still be contained in some data. This becomes problematic because it is possible for a later entity to be spawned at the exact same id! If this happens, which is rare but very possible, it will be logged.

Aliasing can happen without warning. Holding onto a [Entity] id corresponding to an entity well after that entity was despawned can cause un-intuitive behavior for both ordering, and comparing in general. To prevent these bugs, it is generally best practice to stop holding an [Entity] or [EntityGeneration] value as soon as you know it has been despawned. If you must do otherwise, do not assume the [Entity] id corresponds to the same entity it originally did. See [EntityGeneration]’s docs for more information about aliasing and why it occurs.

Stability warning

For all intents and purposes, Entity should be treated as an opaque identifier. The internal bit representation is liable to change from release to release as are the behaviors or performance characteristics of any of its trait implementations (i.e. Ord, Hash, etc.). This means that changes in Entity’s representation, though made readable through various functions on the type, are not considered breaking changes under SemVer.

In particular, directly serializing with Serialize and Deserialize make zero guarantee of long term wire format compatibility. Changes in behavior will cause serialized Entity values persisted to long term storage (i.e. disk, databases, etc.) will fail to deserialize upon being updated.

Usage

This data type is returned by iterating a Query that has Entity as part of its query fetch type parameter (learn more). It can also be obtained by calling EntityCommands::id or EntityWorldMut::id.

# use bevy_ecs::prelude::*;
# #[derive(Component)]
# struct SomeComponent;
fn setup(mut commands: Commands) {
    // Calling `spawn` returns `EntityCommands`.
    let entity = commands.spawn(SomeComponent).id();
}

fn exclusive_system(world: &mut World) {
    // Calling `spawn` returns `EntityWorldMut`.
    let entity = world.spawn(SomeComponent).id();
}
#
# bevy_ecs::system::assert_is_system(setup);
# bevy_ecs::system::assert_is_system(exclusive_system);

It can be used to refer to a specific entity to apply EntityCommands, or to call Query::get (or similar methods) to access its components.

# use bevy_ecs::prelude::*;
#
# #[derive(Component)]
# struct Expired;
#
fn dispose_expired_food(mut commands: Commands, query: Query<Entity, With<Expired>>) {
    for food_entity in &query {
        commands.entity(food_entity).despawn();
    }
}
#
# bevy_ecs::system::assert_is_system(dispose_expired_food);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
to_bitsThe entity as a single number, which can be turned back into the entity with [`from_bits`](Self::from_bits). Only meaningful while the app is running, don’t save it.
generationHow many times the index of this entity has been reused.
from_bitsThe entity from a number returned by [`to_bits`](Self::to_bits), or nil if the number is not a valid entity.
eqWhether two entities are the same.
indexThe index of the entity. Indices of despawned entities are reused, so compare whole entities to tell...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

to_bits

The entity as a single number, which can be turned back into the entity with from_bits.

Only meaningful while the app is running, don’t save it.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
returnU64No Documentation 🚧

generation

How many times the index of this entity has been reused.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

from_bits

The entity from a number returned by to_bits, or nil if the number is not a valid entity.

Arguments

NameTypeDocumentation
bitsU64No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Entity>No Documentation 🚧

eq

Whether two entities are the same.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧
otherEntityNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

index

The index of the entity. Indices of despawned entities are reused, so compare whole entities to tell them apart.

Arguments

NameTypeDocumentation
_selfEntityNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Entity>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceEntityThe constructed value.

ChildOf

ChildOf

  1. Entity

Description

Stores the parent entity of this child entity with this component.

This is a Relationship component, and creates the canonical “parent / child” hierarchy. This is the “source of truth” component, and it pairs with the [Children] RelationshipTarget.

This relationship should be used for things like:

  1. Organizing entities in a scene
  2. Propagating configuration or data inherited from a parent, such as “visibility” or “world-space global transforms”.
  3. Ensuring a hierarchy is despawned when an entity is despawned.

[ChildOf] contains a single “target” [Entity]. When [ChildOf] is inserted on a “source” entity, the “target” entity will automatically (and immediately, via a component hook) have a [Children] component inserted, and the “source” entity will be added to that [Children] instance.

If the [ChildOf] component is replaced with a different “target” entity, the old target’s [Children] will be automatically (and immediately, via a component hook) be updated to reflect that change.

Likewise, when the [ChildOf] component is removed, the “source” entity will be removed from the old target’s [Children]. If this results in [Children] being empty, [Children] will be automatically removed.

When a parent is despawned, all children (and their descendants) will also be despawned.

You can create parent-child relationships in a variety of ways. The most direct way is to insert a [ChildOf] component:

# use bevy_ecs::prelude::*;
# let mut world = World::new();
let root = world.spawn_empty().id();
let child1 = world.spawn(ChildOf(root)).id();
let child2 = world.spawn(ChildOf(root)).id();
let grandchild = world.spawn(ChildOf(child1)).id();

assert_eq!(&**world.entity(root).get::<Children>().unwrap(), &[child1, child2]);
assert_eq!(&**world.entity(child1).get::<Children>().unwrap(), &[grandchild]);

world.entity_mut(child2).remove::<ChildOf>();
assert_eq!(&**world.entity(root).get::<Children>().unwrap(), &[child1]);

world.entity_mut(root).despawn();
assert!(world.get_entity(root).is_err());
assert!(world.get_entity(child1).is_err());
assert!(world.get_entity(grandchild).is_err());

However if you are spawning many children, you might want to use the [EntityWorldMut::with_children] helper instead:

# use bevy_ecs::prelude::*;
# let mut world = World::new();
let mut child1 = None;
let mut child2 = None;
let mut grandchild = None;
let root = world.spawn_empty().with_children(|p| {
    child1 = Some(p.spawn_empty().with_children(|p| {
        grandchild = Some(p.spawn_empty().id());
    }).id());
    child2 = Some(p.spawn_empty().id());
}).id();

assert_eq!(&**world.entity(root).get::<Children>().unwrap(), &[child1.unwrap(), child2.unwrap()]);
assert_eq!(&**world.entity(child1.unwrap()).get::<Children>().unwrap(), &[grandchild.unwrap()]);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
parentThe parent entity.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

parent

The parent entity.

Arguments

NameTypeDocumentation
_selfChildOfNo Documentation 🚧

Returns

NameTypeDocumentation
returnEntityNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ChildOf>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceChildOfThe constructed value.

Name

Name

  1. HashedStr

Description

Component used to identify an entity. Stores a hash for faster comparisons.

The hash is eagerly re-computed upon each update to the name.

[Name] should not be treated as a globally unique identifier for entities, as multiple entities can have the same name. [Entity] should be used instead as the default unique identifier.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
eqWhether the name is the same as another name or a string. In Lua, `==` only compares a name with an...
as_strThe name as a string.
newCreates a new [`Name`](bevy_ecs::name::Name) component, used to identify entities. ```multi-lang-example,lua local Name = import_namespace(“ecs”).Name local name = Name.new(“player”) assert(name:as_str() == “player”) ``` ```multi-lang-example,rune let Name = import_namespace(“ecs”).Name; let name = Name.new(“player”); assert!(name.as_str() == “player”); ```
setChanges the name.

eq

Whether the name is the same as another name or a string.

In Lua, == only compares a name with another name, use name:eq("text") for strings.

Arguments

NameTypeDocumentation
_selfNameNo Documentation 🚧
otherNameString

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

as_str

The name as a string.

Arguments

NameTypeDocumentation
_selfNameNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

new

Creates a new Name component, used to identify entities.

local Name = import_namespace("ecs").Name
local name = Name.new("player")
assert(name:as_str() == "player")
let Name = import_namespace("ecs").Name;
let name = Name.new("player");
assert!(name.as_str() == "player");

Arguments

NameTypeDocumentation
nameStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnNameNo Documentation 🚧

set

Changes the name.

Arguments

NameTypeDocumentation
_selfNameNo Documentation 🚧
nameStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

ComponentId

ComponentId

  1. Usize

Description

A value which uniquely identifies the type of a [Component] or Resource within a World.

Each time a new Component type is registered within a World using e.g. World::register_component or World::register_component_with_descriptor or a Resource with e.g. World::init_resource, a corresponding ComponentId is created to track it.

While the distinction between ComponentId and [TypeId] may seem superficial, breaking them into two separate but related concepts allows components to exist outside of Rust’s type system. Each Rust type registered as a Component will have a corresponding ComponentId, but additional ComponentIds may exist in a World to track components which cannot be represented as Rust types for scripting or other advanced use-cases.

A ComponentId is tightly coupled to its parent World. Attempting to use a ComponentId from one World to access the metadata of a Component in a different World is undefined behavior and must not be attempted.

Given a type T which implements [Component] (including Resource), the ComponentId for T can be retrieved from a World using World::component_id() or via [Components::component_id()].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ComponentId>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceComponentIdThe constructed value.

AddEvent

AddEvent

Description

Trigger emitted when a component is inserted onto an entity that does not already have that component. Runs before Insert. See ComponentHooks::on_add for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AddEvent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAddEventThe constructed value.

DespawnEvent

DespawnEvent

Description

[EntityEvent] emitted for each component on an entity when it is despawned. See ComponentHooks::on_despawn for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<DespawnEvent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDespawnEventThe constructed value.

DiscardEvent

DiscardEvent

Description

Trigger emitted when a component is removed from an entity, regardless of whether or not it is later replaced.

Runs before the value is replaced, so you can still access the original component data. See ComponentHooks::on_discard for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<DiscardEvent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDiscardEventThe constructed value.

InsertEvent

InsertEvent

Description

Trigger emitted when a component is inserted, regardless of whether or not the entity already had that component. Runs after Add, if it ran. See ComponentHooks::on_insert for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InsertEvent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInsertEventThe constructed value.

RemoveEvent

RemoveEvent

Description

Trigger emitted when a component is removed from an entity, and runs before the component is removed, so you can still access the component data. See ComponentHooks::on_remove for more information.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RemoveEvent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRemoveEventThe constructed value.

HashedStr

HashedStr

  1. Hashed<Cow, TypeId(0x4ee5fc7c26dac803f8abc5b33940c653)>

Description

A wrapper over Hashed. This exists to make Name(“value”.into()) possible, which plays nicely with contexts like the bsn! macro.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<HashedStr>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceHashedStrThe constructed value.

gizmos

The types and functions in the gizmos namespace, as returned by import_namespace("gizmos").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
GizmosImmediate mode debug drawing: lines and shapes drawn this frame. Every function draws straight aw...

Values

NameType
FrustumGizmoSystemsReflectSystemSet
GizmoMeshSystemsReflectSystemSet
TransformGizmoSystemsReflectSystemSet

Gizmos

Gizmos

Description

Immediate mode debug drawing: lines and shapes drawn this frame.

Every function draws straight away, the shapes are shown for the current frame only. Needs the gizmo plugin, without it the functions fail with an error.

local Color = import_namespace("color").Color
local Gizmos = import_namespace("gizmos").Gizmos
local Vec3 = import_namespace("math").Vec3
Gizmos.line(Vec3.zero(), Vec3.new(1, 0, 0), Color.white())
let Color = import_namespace("color").Color;
let Gizmos = import_namespace("gizmos").Gizmos;
let Vec3 = import_namespace("math").Vec3;
Gizmos.line(Vec3.zero(), Vec3.new(1.0, 0.0, 0.0), Color.white());

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
cuboidDraws a unit cube, with the transform applied to it.
linestrip_2dDraws connected lines through the points in 2D, in order.
lineDraws a line between two points.
arrowDraws an arrow from the start to the end point.
rect_2dDraws a rectangle of the given size centred on the position in 2D.
circleDraws a circle around the position, lying in the XY plane so it faces +Z.
rectDraws a rectangle of the given size centred on the position, lying in the XY plane.
rayDraws a line from the origin along the vector.
ray_2dDraws a line from the origin along the vector in 2D.
axesDraws the red, green and blue axes of the transform, scaled by the length.
circle_2dDraws a circle around the position in 2D.
linestripDraws connected lines through the points, in order.
arrow_2dDraws an arrow from the start to the end point in 2D.
sphereDraws a wireframe sphere around the position.
line_2dDraws a line between two points in 2D.
crossDraws a cross of the given half size along the three axes, centred on the position.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

cuboid

Draws a unit cube, with the transform applied to it.

Arguments

NameTypeDocumentation
transformTransformNo Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

linestrip_2d

Draws connected lines through the points in 2D, in order.

Arguments

NameTypeDocumentation
pointsVec<Vec2>No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

line

Draws a line between two points.

Arguments

NameTypeDocumentation
startVec3No Documentation 🚧
endVec3No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

arrow

Draws an arrow from the start to the end point.

Arguments

NameTypeDocumentation
startVec3No Documentation 🚧
endVec3No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rect_2d

Draws a rectangle of the given size centred on the position in 2D.

Arguments

NameTypeDocumentation
positionVec2No Documentation 🚧
sizeVec2No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

circle

Draws a circle around the position, lying in the XY plane so it faces +Z.

Arguments

NameTypeDocumentation
positionVec3No Documentation 🚧
radiusF32No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rect

Draws a rectangle of the given size centred on the position, lying in the XY plane.

Arguments

NameTypeDocumentation
positionVec3No Documentation 🚧
sizeVec2No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

ray

Draws a line from the origin along the vector.

Arguments

NameTypeDocumentation
originVec3No Documentation 🚧
vectorVec3No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

ray_2d

Draws a line from the origin along the vector in 2D.

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
vectorVec2No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

axes

Draws the red, green and blue axes of the transform, scaled by the length.

Arguments

NameTypeDocumentation
transformTransformNo Documentation 🚧
lengthF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

circle_2d

Draws a circle around the position in 2D.

Arguments

NameTypeDocumentation
positionVec2No Documentation 🚧
radiusF32No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

linestrip

Draws connected lines through the points, in order.

Arguments

NameTypeDocumentation
pointsVec<Vec3>No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

arrow_2d

Draws an arrow from the start to the end point in 2D.

Arguments

NameTypeDocumentation
startVec2No Documentation 🚧
endVec2No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

sphere

Draws a wireframe sphere around the position.

Arguments

NameTypeDocumentation
positionVec3No Documentation 🚧
radiusF32No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

line_2d

Draws a line between two points in 2D.

Arguments

NameTypeDocumentation
startVec2No Documentation 🚧
endVec2No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

cross

Draws a cross of the given half size along the three axes, centred on the position.

Arguments

NameTypeDocumentation
positionVec3No Documentation 🚧
half_sizeF32No Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Gizmos>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGizmosThe constructed value.

input

The types and functions in the input namespace, as returned by import_namespace("input").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
GamepadStores a connected gamepad’s metadata such as the name and its [`GamepadButton`] and [`GamepadAxis`...
KeyCodeThe key code of a [`KeyboardInput`]. ## Usage It is used as the generic `T` value of an [`ButtonInput`...
MouseButtonA button on a mouse device. ## Usage It is used as the generic `T` value of an [`ButtonInput`] to create a `bevy` resource. ## Updating The resource is updated inside of the [`mouse_button_input_system`]...
InputFocusResource representing which entity has input focus, if any. Input events (other than pointer-like i...
ButtonInput<GamepadButton>A “press-able” input of type `T`. ## Usage This type can be used as a resource to keep the curr...
ButtonInput<KeyCode>A “press-able” input of type `T`. ## Usage This type can be used as a resource to keep the curr...
ButtonInput<MouseButton>A “press-able” input of type `T`. ## Usage This type can be used as a resource to keep the curr...
GamepadAxisRepresents gamepad input types that are mapped in the range [-1.0, 1.0]. ## Usage This is used to determine which axis has changed its value when receiving a gamepad axis event. It is also used in the [`Gamepad`]...
GamepadButtonRepresents gamepad input types that are mapped in the range [0.0, 1.0]. ## Usage This is used to determine which button has changed its value when receiving gamepad button events. It is also used in the [`Gamepad`]...
GamepadInputEncapsulation over [`GamepadAxis`] and [`GamepadButton`].
NativeKeyCodeContains the platform-native physical key identifier The exact values vary from platform to platf...
FocusCauseThe cause for a [`FocusGained`] Sometimes widgets would like to know how their focus was gained so they can act accordingly. For example, a text input may want to select all text when navigated into, but not when pressed.
Axis<GamepadInput>Stores the position data of the input devices of type `T`. The values are stored as `f32`s, using...

Values

NameType
InputSystemsReflectSystemSet

Gamepad

Gamepad

Description

Stores a connected gamepad’s metadata such as the name and its [GamepadButton] and [GamepadAxis].

An entity with this component is spawned automatically after [GamepadConnectionEvent] and updated by [gamepad_event_processing_system].

See also [GamepadSettings] for configuration.

Examples

# use bevy_input::gamepad::{Gamepad, GamepadAxis, GamepadButton};
# use bevy_ecs::system::Query;
# use bevy_ecs::name::Name;
#
fn gamepad_usage_system(gamepads: Query<(&Name, &Gamepad)>) {
    for (name, gamepad) in &gamepads {
        println!("{name}");

        if gamepad.just_pressed(GamepadButton::North) {
            println!("{} just pressed North", name)
        }

        if let Some(left_stick_x) = gamepad.get(GamepadAxis::LeftStickX)  {
            println!("left stick X: {}", left_stick_x)
        }
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
left_stickThe position of the left stick, from `-1` to `1` on each axis.
right_stickThe position of the right stick, from `-1` to `1` on each axis.
just_pressedWhether the button was pressed during the last update.
pressedWhether the button is held down.
getThe value of the button or axis, from `0` to `1` for buttons and from `-1` to `1` for axes, or nil i...
dpadThe direction of the d-pad, from `-1` to `1` on each axis.
just_releasedWhether the button was released during the last update.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

left_stick

The position of the left stick, from -1 to 1 on each axis.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

right_stick

The position of the right stick, from -1 to 1 on each axis.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

just_pressed

Whether the button was pressed during the last update.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pressed

Whether the button is held down.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get

The value of the button or axis, from 0 to 1 for buttons and from -1 to 1 for axes, or nil if the gamepad has no such input.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
axisGamepadAxisNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<F32>No Documentation 🚧

dpad

The direction of the d-pad, from -1 to 1 on each axis.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

just_released

Whether the button was released during the last update.

Arguments

NameTypeDocumentation
_selfGamepadNo Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Gamepad>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGamepadThe constructed value.

KeyCode

Unidentified

  1. NativeKeyCode

Backquote

Backslash

BracketLeft

BracketRight

Comma

Digit0

Digit1

Digit2

Digit3

Digit4

Digit5

Digit6

Digit7

Digit8

Digit9

Equal

IntlBackslash

IntlRo

IntlYen

KeyA

KeyB

KeyC

KeyD

KeyE

KeyF

KeyG

KeyH

KeyI

KeyJ

KeyK

KeyL

KeyM

KeyN

KeyO

KeyP

KeyQ

KeyR

KeyS

KeyT

KeyU

KeyV

KeyW

KeyX

KeyY

KeyZ

Minus

Period

Quote

Semicolon

Slash

AltLeft

AltRight

Backspace

CapsLock

ContextMenu

ControlLeft

ControlRight

Enter

SuperLeft

SuperRight

ShiftLeft

ShiftRight

Space

Tab

Convert

KanaMode

Lang1

Lang2

Lang3

Lang4

Lang5

NonConvert

Delete

End

Help

Home

Insert

PageDown

PageUp

ArrowDown

ArrowLeft

ArrowRight

ArrowUp

NumLock

Numpad0

Numpad1

Numpad2

Numpad3

Numpad4

Numpad5

Numpad6

Numpad7

Numpad8

Numpad9

NumpadAdd

NumpadBackspace

NumpadClear

NumpadClearEntry

NumpadComma

NumpadDecimal

NumpadDivide

NumpadEnter

NumpadEqual

NumpadHash

NumpadMemoryAdd

NumpadMemoryClear

NumpadMemoryRecall

NumpadMemoryStore

NumpadMemorySubtract

NumpadMultiply

NumpadParenLeft

NumpadParenRight

NumpadStar

NumpadSubtract

Escape

Fn

FnLock

PrintScreen

ScrollLock

Pause

BrowserBack

BrowserFavorites

BrowserForward

BrowserHome

BrowserRefresh

BrowserSearch

BrowserStop

Eject

LaunchApp1

LaunchApp2

LaunchMail

MediaPlayPause

MediaSelect

MediaStop

MediaTrackNext

MediaTrackPrevious

Power

Sleep

AudioVolumeDown

AudioVolumeMute

AudioVolumeUp

WakeUp

Meta

Hyper

Turbo

Abort

Resume

Suspend

Again

Copy

Cut

Find

Open

Paste

Props

Select

Undo

Hiragana

Katakana

F1

F2

F3

F4

F5

F6

F7

F8

F9

F10

F11

F12

F13

F14

F15

F16

F17

F18

F19

F20

F21

F22

F23

F24

F25

F26

F27

F28

F29

F30

F31

F32

F33

F34

F35

Description

The key code of a [KeyboardInput].

Usage

It is used as the generic T value of an [ButtonInput] to create a Res<ButtonInput<KeyCode>>.

Code representing the location of a physical key This mostly conforms to the UI Events Specification's KeyboardEvent.code with a few exceptions:

  • The keys that the specification calls MetaLeft and MetaRight are named SuperLeft and SuperRight here.
  • The key that the specification calls “Super” is reported as Unidentified here.

Updating

The resource is updated inside of the [keyboard_input_system].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
any_pressedWhether any of the keys is held down.
get_pressedThe keys which are held down.
get_just_pressedThe keys which were pressed during the last update.
just_releasedWhether the key was released during the last update.
just_pressedWhether the key was pressed during the last update.
any_just_pressedWhether any of the keys was pressed during the last update.
pressedWhether the key is held down, false if the input resource is missing.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Abort.newNo Documentation 🚧
Again.newNo Documentation 🚧
AltLeft.newNo Documentation 🚧
AltRight.newNo Documentation 🚧
ArrowDown.newNo Documentation 🚧
ArrowLeft.newNo Documentation 🚧
ArrowRight.newNo Documentation 🚧
ArrowUp.newNo Documentation 🚧
AudioVolumeDown.newNo Documentation 🚧
AudioVolumeMute.newNo Documentation 🚧
AudioVolumeUp.newNo Documentation 🚧
Backquote.newNo Documentation 🚧
Backslash.newNo Documentation 🚧
Backspace.newNo Documentation 🚧
BracketLeft.newNo Documentation 🚧
BracketRight.newNo Documentation 🚧
BrowserBack.newNo Documentation 🚧
BrowserFavorites.newNo Documentation 🚧
BrowserForward.newNo Documentation 🚧
BrowserHome.newNo Documentation 🚧
BrowserRefresh.newNo Documentation 🚧
BrowserSearch.newNo Documentation 🚧
BrowserStop.newNo Documentation 🚧
CapsLock.newNo Documentation 🚧
Comma.newNo Documentation 🚧
ContextMenu.newNo Documentation 🚧
ControlLeft.newNo Documentation 🚧
ControlRight.newNo Documentation 🚧
Convert.newNo Documentation 🚧
Copy.newNo Documentation 🚧
Cut.newNo Documentation 🚧
Delete.newNo Documentation 🚧
Digit0.newNo Documentation 🚧
Digit1.newNo Documentation 🚧
Digit2.newNo Documentation 🚧
Digit3.newNo Documentation 🚧
Digit4.newNo Documentation 🚧
Digit5.newNo Documentation 🚧
Digit6.newNo Documentation 🚧
Digit7.newNo Documentation 🚧
Digit8.newNo Documentation 🚧
Digit9.newNo Documentation 🚧
Eject.newNo Documentation 🚧
End.newNo Documentation 🚧
Enter.newNo Documentation 🚧
Equal.newNo Documentation 🚧
Escape.newNo Documentation 🚧
F10.newNo Documentation 🚧
F11.newNo Documentation 🚧
F12.newNo Documentation 🚧
F13.newNo Documentation 🚧
F14.newNo Documentation 🚧
F15.newNo Documentation 🚧
F16.newNo Documentation 🚧
F17.newNo Documentation 🚧
F18.newNo Documentation 🚧
F19.newNo Documentation 🚧
F1.newNo Documentation 🚧
F20.newNo Documentation 🚧
F21.newNo Documentation 🚧
F22.newNo Documentation 🚧
F23.newNo Documentation 🚧
F24.newNo Documentation 🚧
F25.newNo Documentation 🚧
F26.newNo Documentation 🚧
F27.newNo Documentation 🚧
F28.newNo Documentation 🚧
F29.newNo Documentation 🚧
F2.newNo Documentation 🚧
F30.newNo Documentation 🚧
F31.newNo Documentation 🚧
F32.newNo Documentation 🚧
F33.newNo Documentation 🚧
F34.newNo Documentation 🚧
F35.newNo Documentation 🚧
F3.newNo Documentation 🚧
F4.newNo Documentation 🚧
F5.newNo Documentation 🚧
F6.newNo Documentation 🚧
F7.newNo Documentation 🚧
F8.newNo Documentation 🚧
F9.newNo Documentation 🚧
Find.newNo Documentation 🚧
Fn.newNo Documentation 🚧
FnLock.newNo Documentation 🚧
Help.newNo Documentation 🚧
Hiragana.newNo Documentation 🚧
Home.newNo Documentation 🚧
Hyper.newNo Documentation 🚧
Insert.newNo Documentation 🚧
IntlBackslash.newNo Documentation 🚧
IntlRo.newNo Documentation 🚧
IntlYen.newNo Documentation 🚧
KanaMode.newNo Documentation 🚧
Katakana.newNo Documentation 🚧
KeyA.newNo Documentation 🚧
KeyB.newNo Documentation 🚧
KeyC.newNo Documentation 🚧
KeyD.newNo Documentation 🚧
KeyE.newNo Documentation 🚧
KeyF.newNo Documentation 🚧
KeyG.newNo Documentation 🚧
KeyH.newNo Documentation 🚧
KeyI.newNo Documentation 🚧
KeyJ.newNo Documentation 🚧
KeyK.newNo Documentation 🚧
KeyL.newNo Documentation 🚧
KeyM.newNo Documentation 🚧
KeyN.newNo Documentation 🚧
KeyO.newNo Documentation 🚧
KeyP.newNo Documentation 🚧
KeyQ.newNo Documentation 🚧
KeyR.newNo Documentation 🚧
KeyS.newNo Documentation 🚧
KeyT.newNo Documentation 🚧
KeyU.newNo Documentation 🚧
KeyV.newNo Documentation 🚧
KeyW.newNo Documentation 🚧
KeyX.newNo Documentation 🚧
KeyY.newNo Documentation 🚧
KeyZ.newNo Documentation 🚧
Lang1.newNo Documentation 🚧
Lang2.newNo Documentation 🚧
Lang3.newNo Documentation 🚧
Lang4.newNo Documentation 🚧
Lang5.newNo Documentation 🚧
LaunchApp1.newNo Documentation 🚧
LaunchApp2.newNo Documentation 🚧
LaunchMail.newNo Documentation 🚧
MediaPlayPause.newNo Documentation 🚧
MediaSelect.newNo Documentation 🚧
MediaStop.newNo Documentation 🚧
MediaTrackNext.newNo Documentation 🚧
MediaTrackPrevious.newNo Documentation 🚧
Meta.newNo Documentation 🚧
Minus.newNo Documentation 🚧
NonConvert.newNo Documentation 🚧
NumLock.newNo Documentation 🚧
Numpad0.newNo Documentation 🚧
Numpad1.newNo Documentation 🚧
Numpad2.newNo Documentation 🚧
Numpad3.newNo Documentation 🚧
Numpad4.newNo Documentation 🚧
Numpad5.newNo Documentation 🚧
Numpad6.newNo Documentation 🚧
Numpad7.newNo Documentation 🚧
Numpad8.newNo Documentation 🚧
Numpad9.newNo Documentation 🚧
NumpadAdd.newNo Documentation 🚧
NumpadBackspace.newNo Documentation 🚧
NumpadClear.newNo Documentation 🚧
NumpadClearEntry.newNo Documentation 🚧
NumpadComma.newNo Documentation 🚧
NumpadDecimal.newNo Documentation 🚧
NumpadDivide.newNo Documentation 🚧
NumpadEnter.newNo Documentation 🚧
NumpadEqual.newNo Documentation 🚧
NumpadHash.newNo Documentation 🚧
NumpadMemoryAdd.newNo Documentation 🚧
NumpadMemoryClear.newNo Documentation 🚧
NumpadMemoryRecall.newNo Documentation 🚧
NumpadMemoryStore.newNo Documentation 🚧
NumpadMemorySubtract.newNo Documentation 🚧
NumpadMultiply.newNo Documentation 🚧
NumpadParenLeft.newNo Documentation 🚧
NumpadParenRight.newNo Documentation 🚧
NumpadStar.newNo Documentation 🚧
NumpadSubtract.newNo Documentation 🚧
Open.newNo Documentation 🚧
PageDown.newNo Documentation 🚧
PageUp.newNo Documentation 🚧
Paste.newNo Documentation 🚧
Pause.newNo Documentation 🚧
Period.newNo Documentation 🚧
Power.newNo Documentation 🚧
PrintScreen.newNo Documentation 🚧
Props.newNo Documentation 🚧
Quote.newNo Documentation 🚧
Resume.newNo Documentation 🚧
ScrollLock.newNo Documentation 🚧
Select.newNo Documentation 🚧
Semicolon.newNo Documentation 🚧
ShiftLeft.newNo Documentation 🚧
ShiftRight.newNo Documentation 🚧
Slash.newNo Documentation 🚧
Sleep.newNo Documentation 🚧
Space.newNo Documentation 🚧
SuperLeft.newNo Documentation 🚧
SuperRight.newNo Documentation 🚧
Suspend.newNo Documentation 🚧
Tab.newNo Documentation 🚧
Turbo.newNo Documentation 🚧
Undo.newNo Documentation 🚧
Unidentified.newNo Documentation 🚧
WakeUp.newNo Documentation 🚧

any_pressed

Whether any of the keys is held down.

Arguments

NameTypeDocumentation
keysVec<KeyCode>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get_pressed

The keys which are held down.

Arguments

Returns

NameTypeDocumentation
returnVec<KeyCode>No Documentation 🚧

get_just_pressed

The keys which were pressed during the last update.

Arguments

Returns

NameTypeDocumentation
returnVec<KeyCode>No Documentation 🚧

just_released

Whether the key was released during the last update.

Arguments

NameTypeDocumentation
keyKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

just_pressed

Whether the key was pressed during the last update.

Arguments

NameTypeDocumentation
keyKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

any_just_pressed

Whether any of the keys was pressed during the last update.

Arguments

NameTypeDocumentation
keysVec<KeyCode>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pressed

Whether the key is held down, false if the input resource is missing.

Arguments

NameTypeDocumentation
keyKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<KeyCode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceKeyCodeThe constructed value.

Abort.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Abort>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Again.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Again>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

AltLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::AltLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

AltRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::AltRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ArrowDown.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ArrowDown>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ArrowLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ArrowLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ArrowRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ArrowRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ArrowUp.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ArrowUp>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

AudioVolumeDown.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::AudioVolumeDown>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

AudioVolumeMute.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::AudioVolumeMute>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

AudioVolumeUp.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::AudioVolumeUp>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Backquote.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Backquote>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Backslash.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Backslash>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Backspace.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Backspace>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BracketLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BracketLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BracketRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BracketRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserBack.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserBack>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserFavorites.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserFavorites>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserForward.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserForward>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserHome.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserHome>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserRefresh.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserRefresh>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserSearch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserSearch>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

BrowserStop.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::BrowserStop>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

CapsLock.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::CapsLock>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Comma.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Comma>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ContextMenu.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ContextMenu>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ControlLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ControlLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ControlRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ControlRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Convert.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Convert>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Copy.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Copy>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Cut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Cut>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Delete.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Delete>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit0.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit0>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit1>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit2>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit3.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit3>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit4.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit4>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit5.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit5>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit6.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit6>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit7.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit7>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit8.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit8>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Digit9.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Digit9>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Eject.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Eject>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Enter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Enter>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Equal.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Equal>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Escape.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Escape>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F10.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F10>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F11.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F11>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F12.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F12>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F13.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F13>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F14.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F14>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F15.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F15>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F16.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F16>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F17.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F17>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F18.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F18>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F19.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F19>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F1>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F20.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F20>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F21.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F21>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F22.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F22>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F23.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F23>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F24.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F24>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F25.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F25>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F26.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F26>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F27.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F27>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F28.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F28>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F29.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F29>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F2>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F30.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F30>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F31.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F31>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F32.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F32>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F33.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F33>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F34.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F34>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F35.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F35>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F3.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F3>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F4.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F4>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F5.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F5>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F6.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F6>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F7.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F7>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F8.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F8>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

F9.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::F9>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Find.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Find>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Fn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Fn>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

FnLock.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::FnLock>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Help.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Help>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Hiragana.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Hiragana>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Home.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Home>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Hyper.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Hyper>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Insert.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Insert>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

IntlBackslash.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::IntlBackslash>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

IntlRo.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::IntlRo>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

IntlYen.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::IntlYen>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KanaMode.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KanaMode>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Katakana.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Katakana>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyA.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyA>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyB.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyB>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyC.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyC>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyD.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyD>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyE.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyE>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyF.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyF>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyG.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyG>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyH.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyH>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyI.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyI>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyJ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyJ>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyK.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyK>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyL.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyL>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyM.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyM>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyN.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyN>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyO.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyO>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyP.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyP>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyQ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyQ>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyR.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyR>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyS.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyS>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyT.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyT>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyU.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyU>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyV.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyV>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyW.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyW>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyX>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyY>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

KeyZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::KeyZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Lang1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Lang1>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Lang2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Lang2>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Lang3.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Lang3>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Lang4.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Lang4>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Lang5.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Lang5>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

LaunchApp1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::LaunchApp1>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

LaunchApp2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::LaunchApp2>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

LaunchMail.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::LaunchMail>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MediaPlayPause.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::MediaPlayPause>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MediaSelect.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::MediaSelect>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MediaStop.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::MediaStop>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MediaTrackNext.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::MediaTrackNext>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MediaTrackPrevious.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::MediaTrackPrevious>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Meta.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Meta>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Minus.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Minus>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NonConvert.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NonConvert>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumLock.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumLock>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad0.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad0>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad1>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad2>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad3.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad3>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad4.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad4>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad5.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad5>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad6.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad6>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad7.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad7>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad8.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad8>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Numpad9.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Numpad9>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadAdd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadAdd>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadBackspace.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadBackspace>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadClear.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadClear>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadClearEntry.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadClearEntry>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadComma.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadComma>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadDecimal.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadDecimal>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadDivide.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadDivide>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadEnter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadEnter>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadEqual.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadEqual>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadHash.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadHash>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMemoryAdd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMemoryAdd>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMemoryClear.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMemoryClear>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMemoryRecall.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMemoryRecall>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMemoryStore.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMemoryStore>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMemorySubtract.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMemorySubtract>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadMultiply.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadMultiply>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadParenLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadParenLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadParenRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadParenRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadStar.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadStar>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

NumpadSubtract.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::NumpadSubtract>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Open.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Open>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

PageDown.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::PageDown>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

PageUp.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::PageUp>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Paste.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Paste>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Pause.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Pause>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Period.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Period>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Power.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Power>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

PrintScreen.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::PrintScreen>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Props.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Props>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Quote.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Quote>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Resume.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Resume>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ScrollLock.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ScrollLock>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Select.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Select>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Semicolon.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Semicolon>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ShiftLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ShiftLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

ShiftRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::ShiftRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Slash.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Slash>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Sleep.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Sleep>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Space.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Space>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

SuperLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::SuperLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

SuperRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::SuperRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Suspend.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Suspend>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Tab.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Tab>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Turbo.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Turbo>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Undo.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Undo>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

Unidentified.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::Unidentified>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

WakeUp.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<KeyCode::WakeUp>No Documentation 🚧

Returns

NameTypeDocumentation
returnKeyCodeNo Documentation 🚧

MouseButton

Left

Middle

Back

Forward

Other

  1. U16

Description

A button on a mouse device.

Usage

It is used as the generic T value of an [ButtonInput] to create a bevy resource.

Updating

The resource is updated inside of the [mouse_button_input_system].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
just_releasedWhether the mouse button was released during the last update.
any_pressedWhether any of the mouse buttons is held down.
any_just_pressedWhether any of the mouse buttons was pressed during the last update.
get_pressedThe mouse buttons which are held down.
pressedWhether the mouse button is held down, false if the input resource is missing.
just_pressedWhether the mouse button was pressed during the last update.
get_just_pressedThe mouse buttons which were pressed during the last update.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Back.newNo Documentation 🚧
Forward.newNo Documentation 🚧
Left.newNo Documentation 🚧
Middle.newNo Documentation 🚧
Other.newNo Documentation 🚧
Right.newNo Documentation 🚧

just_released

Whether the mouse button was released during the last update.

Arguments

NameTypeDocumentation
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

any_pressed

Whether any of the mouse buttons is held down.

Arguments

NameTypeDocumentation
buttonsVec<MouseButton>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

any_just_pressed

Whether any of the mouse buttons was pressed during the last update.

Arguments

NameTypeDocumentation
buttonsVec<MouseButton>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get_pressed

The mouse buttons which are held down.

Arguments

Returns

NameTypeDocumentation
returnVec<MouseButton>No Documentation 🚧

pressed

Whether the mouse button is held down, false if the input resource is missing.

Arguments

NameTypeDocumentation
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

just_pressed

Whether the mouse button was pressed during the last update.

Arguments

NameTypeDocumentation
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get_just_pressed

The mouse buttons which were pressed during the last update.

Arguments

Returns

NameTypeDocumentation
returnVec<MouseButton>No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MouseButton>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMouseButtonThe constructed value.

Back.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Back>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

Forward.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Forward>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

Left.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Left>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

Middle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Middle>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

Other.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Other>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

Right.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MouseButton::Right>No Documentation 🚧

Returns

NameTypeDocumentation
returnMouseButtonNo Documentation 🚧

InputFocus

InputFocus

Description

Resource representing which entity has input focus, if any. Input events (other than pointer-like inputs) will be dispatched to the current focus entity, or to the primary window if no entity has focus.

Changing the input focus is as easy as modifying this resource.

To detect when an entity gains or loses focus, listen for the [FocusGained] and [FocusLost] events.

Examples

From within a system:

#![allow(unused)]
fn main() {
use bevy_ecs::prelude::*;
use bevy_input_focus::{FocusCause, InputFocus};

fn clear_focus(mut input_focus: ResMut<InputFocus>) {
  input_focus.clear();
}
}

With exclusive (or deferred) world access:

#![allow(unused)]
fn main() {
use bevy_ecs::prelude::*;
use bevy_input_focus::{FocusCause, InputFocus};

fn set_focus_from_world(world: &mut World) {
    let entity = world.spawn_empty().id();

    // Fetch the resource from the world
    let mut input_focus = world.resource_mut::<InputFocus>();
    // Then mutate it!
    input_focus.set(entity, FocusCause::Navigated);

    // Or you can just insert a fresh copy of the resource
    // which will overwrite the existing one.
    world.insert_resource(InputFocus::from_entity(entity));
}
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
setGives the focus to the entity, so it receives keyboard input.
getThe entity which has the focus, or nil if no entity has it.
clearTakes the focus away from every entity.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

set

Gives the focus to the entity, so it receives keyboard input.

Arguments

NameTypeDocumentation
_selfInputFocusNo Documentation 🚧
entityEntityNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

get

The entity which has the focus, or nil if no entity has it.

Arguments

NameTypeDocumentation
_selfInputFocusNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Entity>No Documentation 🚧

clear

Takes the focus away from every entity.

Arguments

NameTypeDocumentation
_selfInputFocusNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InputFocus>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInputFocusThe constructed value.

ButtonInput<GamepadButton>

ButtonInput

Description

A “press-able” input of type T.

Usage

This type can be used as a resource to keep the current state of an input, by reacting to events from the input. For a given input value:

  • [ButtonInput::pressed] will return true between a press and a release event.
  • [ButtonInput::just_pressed] will return true for one frame after a press event.
  • [ButtonInput::just_released] will return true for one frame after a release event.

Multiple systems

In case multiple systems are checking for [ButtonInput::just_pressed] or [ButtonInput::just_released] but only one should react, for example when modifying a [Resource], you should consider clearing the input state, either by:

  • Using [ButtonInput::clear_just_pressed] or [ButtonInput::clear_just_released] instead.
  • Calling [ButtonInput::clear] or [ButtonInput::reset] immediately after the state change.

Performance

For all operations, the following conventions are used:

  • n is the number of stored inputs.
  • m is the number of input arguments passed to the method.
  • *-suffix denotes an amortized cost.
  • ~-suffix denotes an expected cost.

See Rust’s std::collections doc on performance for more details on the conventions used here.

[ButtonInput] operationsComputational complexity
[ButtonInput::any_just_pressed]O(m)~
[ButtonInput::any_just_released]O(m)~
[ButtonInput::any_pressed]O(m)~
[ButtonInput::get_just_pressed]O(n)
[ButtonInput::get_just_released]O(n)
[ButtonInput::get_pressed]O(n)
[ButtonInput::just_pressed]O(1)~
[ButtonInput::just_released]O(1)~
[ButtonInput::pressed]O(1)~
[ButtonInput::press]O(1)~*
[ButtonInput::release]O(1)~*
[ButtonInput::release_all]O(n)~*
[ButtonInput::clear_just_pressed]O(1)~
[ButtonInput::clear_just_released]O(1)~
[ButtonInput::reset_all]O(n)
[ButtonInput::clear]O(n)

Window focus

ButtonInput<KeyCode> is tied to window focus. For example, if the user holds a button while the window loses focus, [ButtonInput::just_released] will be triggered. Similarly if the window regains focus, [ButtonInput::just_pressed] will be triggered.

ButtonInput<GamepadButton> is independent of window focus.

Examples

Reading and checking against the current set of pressed buttons:

# use bevy_app::{App, NoopPluginGroup as DefaultPlugins, Update};
# use bevy_ecs::{prelude::{IntoScheduleConfigs, Res, Resource, resource_changed}, schedule::SystemCondition};
# use bevy_input::{ButtonInput, prelude::{KeyCode, MouseButton}};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(
            Update,
            print_mouse.run_if(resource_changed::<ButtonInput<MouseButton>>),
        )
        .add_systems(
            Update,
            print_keyboard.run_if(resource_changed::<ButtonInput<KeyCode>>),
        )
        .run();
}

fn print_mouse(mouse: Res<ButtonInput<MouseButton>>) {
    println!("Mouse: {:?}", mouse.get_pressed().collect::<Vec<_>>());
}

fn print_keyboard(keyboard: Res<ButtonInput<KeyCode>>) {
    if keyboard.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight])
        && keyboard.any_pressed([KeyCode::AltLeft, KeyCode::AltRight])
        && keyboard.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight])
        && keyboard.any_pressed([KeyCode::SuperLeft, KeyCode::SuperRight])
        && keyboard.pressed(KeyCode::KeyL)
    {
        println!("On Windows this opens LinkedIn.");
    } else {
        println!("keyboard: {:?}", keyboard.get_pressed().collect::<Vec<_>>());
    }
}

Note

When adding this resource for a new input type, you should:

  • Call the [ButtonInput::press] method for each press event.
  • Call the [ButtonInput::release] method for each release event.
  • Call the [ButtonInput::clear] method at each frame start, before processing events.

Note: Calling clear from a ResMut will trigger change detection. It may be preferable to use DetectChangesMut::bypass_change_detection to avoid causing the resource to always be marked as changed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
releaseLets go of the button, as if it was released.
pressHolds the button down, as if it was pressed.
just_releasedWhether the button was released during the last update.
get_pressedThe buttons which are held down.
just_pressedWhether the button was pressed during the last update.
pressedWhether the button is held down.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

release

Lets go of the button, as if it was released.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

press

Holds the button down, as if it was pressed.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

just_released

Whether the button was released during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get_pressed

The buttons which are held down.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<GamepadButton>No Documentation 🚧

just_pressed

Whether the button was pressed during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pressed

Whether the button is held down.

Arguments

NameTypeDocumentation
_selfButtonInput<GamepadButton>No Documentation 🚧
buttonGamepadButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ButtonInput<GamepadButton>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceButtonInput<GamepadButton>The constructed value.

ButtonInput<KeyCode>

ButtonInput

Description

A “press-able” input of type T.

Usage

This type can be used as a resource to keep the current state of an input, by reacting to events from the input. For a given input value:

  • [ButtonInput::pressed] will return true between a press and a release event.
  • [ButtonInput::just_pressed] will return true for one frame after a press event.
  • [ButtonInput::just_released] will return true for one frame after a release event.

Multiple systems

In case multiple systems are checking for [ButtonInput::just_pressed] or [ButtonInput::just_released] but only one should react, for example when modifying a [Resource], you should consider clearing the input state, either by:

  • Using [ButtonInput::clear_just_pressed] or [ButtonInput::clear_just_released] instead.
  • Calling [ButtonInput::clear] or [ButtonInput::reset] immediately after the state change.

Performance

For all operations, the following conventions are used:

  • n is the number of stored inputs.
  • m is the number of input arguments passed to the method.
  • *-suffix denotes an amortized cost.
  • ~-suffix denotes an expected cost.

See Rust’s std::collections doc on performance for more details on the conventions used here.

[ButtonInput] operationsComputational complexity
[ButtonInput::any_just_pressed]O(m)~
[ButtonInput::any_just_released]O(m)~
[ButtonInput::any_pressed]O(m)~
[ButtonInput::get_just_pressed]O(n)
[ButtonInput::get_just_released]O(n)
[ButtonInput::get_pressed]O(n)
[ButtonInput::just_pressed]O(1)~
[ButtonInput::just_released]O(1)~
[ButtonInput::pressed]O(1)~
[ButtonInput::press]O(1)~*
[ButtonInput::release]O(1)~*
[ButtonInput::release_all]O(n)~*
[ButtonInput::clear_just_pressed]O(1)~
[ButtonInput::clear_just_released]O(1)~
[ButtonInput::reset_all]O(n)
[ButtonInput::clear]O(n)

Window focus

ButtonInput<KeyCode> is tied to window focus. For example, if the user holds a button while the window loses focus, [ButtonInput::just_released] will be triggered. Similarly if the window regains focus, [ButtonInput::just_pressed] will be triggered.

ButtonInput<GamepadButton> is independent of window focus.

Examples

Reading and checking against the current set of pressed buttons:

# use bevy_app::{App, NoopPluginGroup as DefaultPlugins, Update};
# use bevy_ecs::{prelude::{IntoScheduleConfigs, Res, Resource, resource_changed}, schedule::SystemCondition};
# use bevy_input::{ButtonInput, prelude::{KeyCode, MouseButton}};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(
            Update,
            print_mouse.run_if(resource_changed::<ButtonInput<MouseButton>>),
        )
        .add_systems(
            Update,
            print_keyboard.run_if(resource_changed::<ButtonInput<KeyCode>>),
        )
        .run();
}

fn print_mouse(mouse: Res<ButtonInput<MouseButton>>) {
    println!("Mouse: {:?}", mouse.get_pressed().collect::<Vec<_>>());
}

fn print_keyboard(keyboard: Res<ButtonInput<KeyCode>>) {
    if keyboard.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight])
        && keyboard.any_pressed([KeyCode::AltLeft, KeyCode::AltRight])
        && keyboard.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight])
        && keyboard.any_pressed([KeyCode::SuperLeft, KeyCode::SuperRight])
        && keyboard.pressed(KeyCode::KeyL)
    {
        println!("On Windows this opens LinkedIn.");
    } else {
        println!("keyboard: {:?}", keyboard.get_pressed().collect::<Vec<_>>());
    }
}

Note

When adding this resource for a new input type, you should:

  • Call the [ButtonInput::press] method for each press event.
  • Call the [ButtonInput::release] method for each release event.
  • Call the [ButtonInput::clear] method at each frame start, before processing events.

Note: Calling clear from a ResMut will trigger change detection. It may be preferable to use DetectChangesMut::bypass_change_detection to avoid causing the resource to always be marked as changed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
just_pressedWhether the button was pressed during the last update.
pressHolds the button down, as if it was pressed.
releaseLets go of the button, as if it was released.
get_pressedThe buttons which are held down.
just_releasedWhether the button was released during the last update.
pressedWhether the button is held down.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

just_pressed

Whether the button was pressed during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧
buttonKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

press

Holds the button down, as if it was pressed.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧
buttonKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

release

Lets go of the button, as if it was released.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧
buttonKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

get_pressed

The buttons which are held down.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<KeyCode>No Documentation 🚧

just_released

Whether the button was released during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧
buttonKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pressed

Whether the button is held down.

Arguments

NameTypeDocumentation
_selfButtonInput<KeyCode>No Documentation 🚧
buttonKeyCodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ButtonInput<KeyCode>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceButtonInput<KeyCode>The constructed value.

ButtonInput<MouseButton>

ButtonInput

Description

A “press-able” input of type T.

Usage

This type can be used as a resource to keep the current state of an input, by reacting to events from the input. For a given input value:

  • [ButtonInput::pressed] will return true between a press and a release event.
  • [ButtonInput::just_pressed] will return true for one frame after a press event.
  • [ButtonInput::just_released] will return true for one frame after a release event.

Multiple systems

In case multiple systems are checking for [ButtonInput::just_pressed] or [ButtonInput::just_released] but only one should react, for example when modifying a [Resource], you should consider clearing the input state, either by:

  • Using [ButtonInput::clear_just_pressed] or [ButtonInput::clear_just_released] instead.
  • Calling [ButtonInput::clear] or [ButtonInput::reset] immediately after the state change.

Performance

For all operations, the following conventions are used:

  • n is the number of stored inputs.
  • m is the number of input arguments passed to the method.
  • *-suffix denotes an amortized cost.
  • ~-suffix denotes an expected cost.

See Rust’s std::collections doc on performance for more details on the conventions used here.

[ButtonInput] operationsComputational complexity
[ButtonInput::any_just_pressed]O(m)~
[ButtonInput::any_just_released]O(m)~
[ButtonInput::any_pressed]O(m)~
[ButtonInput::get_just_pressed]O(n)
[ButtonInput::get_just_released]O(n)
[ButtonInput::get_pressed]O(n)
[ButtonInput::just_pressed]O(1)~
[ButtonInput::just_released]O(1)~
[ButtonInput::pressed]O(1)~
[ButtonInput::press]O(1)~*
[ButtonInput::release]O(1)~*
[ButtonInput::release_all]O(n)~*
[ButtonInput::clear_just_pressed]O(1)~
[ButtonInput::clear_just_released]O(1)~
[ButtonInput::reset_all]O(n)
[ButtonInput::clear]O(n)

Window focus

ButtonInput<KeyCode> is tied to window focus. For example, if the user holds a button while the window loses focus, [ButtonInput::just_released] will be triggered. Similarly if the window regains focus, [ButtonInput::just_pressed] will be triggered.

ButtonInput<GamepadButton> is independent of window focus.

Examples

Reading and checking against the current set of pressed buttons:

# use bevy_app::{App, NoopPluginGroup as DefaultPlugins, Update};
# use bevy_ecs::{prelude::{IntoScheduleConfigs, Res, Resource, resource_changed}, schedule::SystemCondition};
# use bevy_input::{ButtonInput, prelude::{KeyCode, MouseButton}};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(
            Update,
            print_mouse.run_if(resource_changed::<ButtonInput<MouseButton>>),
        )
        .add_systems(
            Update,
            print_keyboard.run_if(resource_changed::<ButtonInput<KeyCode>>),
        )
        .run();
}

fn print_mouse(mouse: Res<ButtonInput<MouseButton>>) {
    println!("Mouse: {:?}", mouse.get_pressed().collect::<Vec<_>>());
}

fn print_keyboard(keyboard: Res<ButtonInput<KeyCode>>) {
    if keyboard.any_pressed([KeyCode::ControlLeft, KeyCode::ControlRight])
        && keyboard.any_pressed([KeyCode::AltLeft, KeyCode::AltRight])
        && keyboard.any_pressed([KeyCode::ShiftLeft, KeyCode::ShiftRight])
        && keyboard.any_pressed([KeyCode::SuperLeft, KeyCode::SuperRight])
        && keyboard.pressed(KeyCode::KeyL)
    {
        println!("On Windows this opens LinkedIn.");
    } else {
        println!("keyboard: {:?}", keyboard.get_pressed().collect::<Vec<_>>());
    }
}

Note

When adding this resource for a new input type, you should:

  • Call the [ButtonInput::press] method for each press event.
  • Call the [ButtonInput::release] method for each release event.
  • Call the [ButtonInput::clear] method at each frame start, before processing events.

Note: Calling clear from a ResMut will trigger change detection. It may be preferable to use DetectChangesMut::bypass_change_detection to avoid causing the resource to always be marked as changed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
just_releasedWhether the button was released during the last update.
pressedWhether the button is held down.
releaseLets go of the button, as if it was released.
get_pressedThe buttons which are held down.
pressHolds the button down, as if it was pressed.
just_pressedWhether the button was pressed during the last update.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

just_released

Whether the button was released during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

pressed

Whether the button is held down.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

release

Lets go of the button, as if it was released.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

get_pressed

The buttons which are held down.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<MouseButton>No Documentation 🚧

press

Holds the button down, as if it was pressed.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

just_pressed

Whether the button was pressed during the last update.

Arguments

NameTypeDocumentation
_selfButtonInput<MouseButton>No Documentation 🚧
buttonMouseButtonNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ButtonInput<MouseButton>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceButtonInput<MouseButton>The constructed value.

GamepadAxis

LeftStickX

LeftStickY

LeftZ

RightStickX

RightStickY

RightZ

Other

  1. U32

Description

Represents gamepad input types that are mapped in the range [-1.0, 1.0].

Usage

This is used to determine which axis has changed its value when receiving a gamepad axis event. It is also used in the [Gamepad] component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
LeftStickX.newNo Documentation 🚧
LeftStickY.newNo Documentation 🚧
LeftZ.newNo Documentation 🚧
Other.newNo Documentation 🚧
RightStickX.newNo Documentation 🚧
RightStickY.newNo Documentation 🚧
RightZ.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GamepadAxis>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGamepadAxisThe constructed value.

LeftStickX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::LeftStickX>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

LeftStickY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::LeftStickY>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

LeftZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::LeftZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

Other.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::Other>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

RightStickX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::RightStickX>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

RightStickY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::RightStickY>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

RightZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadAxis::RightZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadAxisNo Documentation 🚧

GamepadButton

South

East

North

West

C

Z

LeftTrigger

LeftTrigger2

RightTrigger

RightTrigger2

Select

Start

Mode

LeftThumb

RightThumb

DPadUp

DPadDown

DPadLeft

DPadRight

Other

  1. U32

Description

Represents gamepad input types that are mapped in the range [0.0, 1.0].

Usage

This is used to determine which button has changed its value when receiving gamepad button events. It is also used in the [Gamepad] component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
C.newNo Documentation 🚧
DPadDown.newNo Documentation 🚧
DPadLeft.newNo Documentation 🚧
DPadRight.newNo Documentation 🚧
DPadUp.newNo Documentation 🚧
East.newNo Documentation 🚧
LeftThumb.newNo Documentation 🚧
LeftTrigger2.newNo Documentation 🚧
LeftTrigger.newNo Documentation 🚧
Mode.newNo Documentation 🚧
North.newNo Documentation 🚧
Other.newNo Documentation 🚧
RightThumb.newNo Documentation 🚧
RightTrigger2.newNo Documentation 🚧
RightTrigger.newNo Documentation 🚧
Select.newNo Documentation 🚧
South.newNo Documentation 🚧
Start.newNo Documentation 🚧
West.newNo Documentation 🚧
Z.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GamepadButton>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGamepadButtonThe constructed value.

C.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::C>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

DPadDown.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::DPadDown>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

DPadLeft.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::DPadLeft>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

DPadRight.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::DPadRight>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

DPadUp.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::DPadUp>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

East.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::East>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

LeftThumb.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::LeftThumb>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

LeftTrigger2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::LeftTrigger2>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

LeftTrigger.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::LeftTrigger>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

Mode.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::Mode>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

North.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::North>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

Other.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::Other>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

RightThumb.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::RightThumb>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

RightTrigger2.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::RightTrigger2>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

RightTrigger.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::RightTrigger>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

Select.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::Select>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

South.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::South>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

West.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::West>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

Z.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadButton::Z>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadButtonNo Documentation 🚧

GamepadInput

Axis

  1. GamepadAxis

Button

  1. GamepadButton

Description

Encapsulation over [GamepadAxis] and [GamepadButton].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Axis.newNo Documentation 🚧
Button.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GamepadInput>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGamepadInputThe constructed value.

Axis.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadInput::Axis>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadInputNo Documentation 🚧

Button.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GamepadInput::Button>No Documentation 🚧

Returns

NameTypeDocumentation
returnGamepadInputNo Documentation 🚧

NativeKeyCode

Unidentified

Android

  1. U32

MacOS

  1. U16

Windows

  1. U16

Xkb

  1. U32

Description

Contains the platform-native physical key identifier

The exact values vary from platform to platform (which is part of why this is a per-platform enum), but the values are primarily tied to the key’s physical location on the keyboard.

This enum is primarily used to store raw keycodes when Winit doesn’t map a given native physical key identifier to a meaningful [KeyCode] variant. In the presence of identifiers we haven’t mapped for you yet, this lets you use [KeyCode] to:

  • Correctly match key press and release events.
  • On non-web platforms, support assigning keybinds to virtually any key through a UI.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Android.newNo Documentation 🚧
MacOS.newNo Documentation 🚧
Unidentified.newNo Documentation 🚧
Windows.newNo Documentation 🚧
Xkb.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NativeKeyCode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNativeKeyCodeThe constructed value.

Android.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NativeKeyCode::Android>No Documentation 🚧

Returns

NameTypeDocumentation
returnNativeKeyCodeNo Documentation 🚧

MacOS.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NativeKeyCode::MacOS>No Documentation 🚧

Returns

NameTypeDocumentation
returnNativeKeyCodeNo Documentation 🚧

Unidentified.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NativeKeyCode::Unidentified>No Documentation 🚧

Returns

NameTypeDocumentation
returnNativeKeyCodeNo Documentation 🚧

Windows.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NativeKeyCode::Windows>No Documentation 🚧

Returns

NameTypeDocumentation
returnNativeKeyCodeNo Documentation 🚧

Xkb.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NativeKeyCode::Xkb>No Documentation 🚧

Returns

NameTypeDocumentation
returnNativeKeyCodeNo Documentation 🚧

FocusCause

Pressed

Auto

Description

The cause for a [FocusGained]

Sometimes widgets would like to know how their focus was gained so they can act accordingly.

For example, a text input may want to select all text when navigated into, but not when pressed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Navigated.newNo Documentation 🚧
Pressed.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FocusCause>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFocusCauseThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FocusCause::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnFocusCauseNo Documentation 🚧

Navigated.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FocusCause::Navigated>No Documentation 🚧

Returns

NameTypeDocumentation
returnFocusCauseNo Documentation 🚧

Pressed.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FocusCause::Pressed>No Documentation 🚧

Returns

NameTypeDocumentation
returnFocusCauseNo Documentation 🚧

Axis<GamepadInput>

Axis

Description

Stores the position data of the input devices of type T.

The values are stored as f32s, using [Axis::set]. Use [Axis::get] to retrieve the value clamped between [Axis::MIN] and [Axis::MAX] inclusive, or unclamped using [Axis::get_unclamped].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Axis<GamepadInput>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAxis<GamepadInput>The constructed value.

input.InputFocusSystems

The types and functions in the input.InputFocusSystems namespace, as returned by import_namespace("input.InputFocusSystems").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

Values

NameType
DispatchReflectSystemSet
FocusChangeEventsReflectSystemSet

math

The types and functions in the math namespace, as returned by import_namespace("math").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
EaseFunctionCurve functions over the [unit interval], commonly used for easing transitions. `EaseFunction` can be used on its own to interpolate between `0.0` and `1.0`. It can also be combined with [`EasingCurve`]...
Dir2A normalized vector pointing in a direction in 2D space
Dir3A normalized vector pointing in a direction in 3D space
RectA rectangle defined by two opposite corners. The rectangle is axis aligned, and defined by its mi...
Rot2A 2D rotation. # Example ``` # use approx::assert_relative_eq; # use bevy_math::{Rot2, Vec2}; use std::f32::consts::PI; // Create rotations from counterclockwise angles in radians or degrees let rotation1 = Rot2::radians(PI / 2.0); let rotation2 = Rot2::degrees(45.0); // Get the angle back as radians or degrees assert_eq!(rotation1.as_degrees(), 90.0); assert_eq!(rotation2.as_radians(), PI / 4.0); // “Add” rotations together using `*` #[cfg(feature = “approx”)] assert_relative_eq!(rotation1 * rotation2, Rot2::degrees(135.0)); // Rotate vectors #[cfg(feature = “approx”)] assert_...
AnnulusA primitive shape formed by the region between two circles, also known as a ring.
CircleA circle primitive, representing the set of points some distance from the origin
RectangleA rectangle primitive, which is like a square, except that the width and height can be different
RegularPolygonA polygon centered on the origin where all vertices lie on a circle, equally far apart.
Capsule3dA 3D capsule primitive centered on the origin A three-dimensional capsule is defined as a surface ...
CuboidA cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not required ...
CylinderA cylinder primitive centered on the origin
Plane3dA bounded plane in 3D space. It forms a surface starting from the origin with a defined height and ...
SphereA sphere primitive, representing the set of all points some distance from the origin
TorusA torus primitive, often representing a ring or donut shape The set of points some distance from a...
Ray2dAn infinite half-line starting at `origin` and going in `direction` in 2D space.
Ray3dAn infinite half-line starting at `origin` and going in `direction` in 3D space.
DVec2No Documentation 🚧
DVec3No Documentation 🚧
IVec2No Documentation 🚧
IVec3No Documentation 🚧
Mat3No Documentation 🚧
Mat4No Documentation 🚧
QuatNo Documentation 🚧
UVec2No Documentation 🚧
UVec3No Documentation 🚧
Vec2No Documentation 🚧
Vec3No Documentation 🚧
Vec3ANo Documentation 🚧
Vec4No Documentation 🚧
JumpAtConfiguration options for the [`EaseFunction::Steps`] curves. This closely replicates the [CSS ste...
CompassOctantA compass enum with 8 directions. ```text N (North) ▲ NW │ NE ╲ │ ╱ W (West) ┼─────► E (East) ╱ │ ╲ SW │ SE ▼ S (South) `...
URectA rectangle defined by two opposite corners. The rectangle is axis aligned, and defined by its mi...
Aabb2dA 2D axis-aligned bounding box, or bounding rectangle
Aabb3dA 3D axis-aligned bounding box
Affine2No Documentation 🚧
Affine3ANo Documentation 🚧
EulerRotNo Documentation 🚧
Mat2No Documentation 🚧
Mat3ANo Documentation 🚧

EaseFunction

Linear

QuadraticIn

QuadraticOut

QuadraticInOut

CubicIn

CubicOut

CubicInOut

QuarticIn

QuarticOut

QuarticInOut

QuinticIn

QuinticOut

QuinticInOut

SmoothStepIn

SmoothStepOut

SmoothStep

SmootherStepIn

SmootherStepOut

SmootherStep

SineIn

SineOut

SineInOut

CircularIn

CircularOut

CircularInOut

ExponentialIn

ExponentialOut

ExponentialInOut

ElasticIn

ElasticOut

ElasticInOut

BackIn

BackOut

BackInOut

BounceIn

BounceOut

BounceInOut

Steps

  1. Usize
  2. JumpAt

Elastic

  1. F32

Description

Curve functions over the unit interval, commonly used for easing transitions.

EaseFunction can be used on its own to interpolate between 0.0 and 1.0. It can also be combined with [EasingCurve] to interpolate between other intervals and types, including vectors and rotations.

Example

sample the smoothstep function at various points. This will return None if the parameter is outside the unit interval.

# use bevy_math::prelude::*;
# use bevy_curve::prelude::*;
let f = EaseFunction::SmoothStep;

assert_eq!(f.sample(-1.0), None);
assert_eq!(f.sample(0.0), Some(0.0));
assert_eq!(f.sample(0.5), Some(0.5));
assert_eq!(f.sample(1.0), Some(1.0));
assert_eq!(f.sample(2.0), None);

sample_clamped will clamp the parameter to the unit interval, so it always returns a value.

# use bevy_math::prelude::*;
# use bevy_curve::prelude::*;
# let f = EaseFunction::SmoothStep;
assert_eq!(f.sample_clamped(-1.0), 0.0);
assert_eq!(f.sample_clamped(0.0), 0.0);
assert_eq!(f.sample_clamped(0.5), 0.5);
assert_eq!(f.sample_clamped(1.0), 1.0);
assert_eq!(f.sample_clamped(2.0), 1.0);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
sampleThe eased value at `t`, clamped to between 0 and 1.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
BackIn.newNo Documentation 🚧
BackInOut.newNo Documentation 🚧
BackOut.newNo Documentation 🚧
BounceIn.newNo Documentation 🚧
BounceInOut.newNo Documentation 🚧
BounceOut.newNo Documentation 🚧
CircularIn.newNo Documentation 🚧
CircularInOut.newNo Documentation 🚧
CircularOut.newNo Documentation 🚧
CubicIn.newNo Documentation 🚧
CubicInOut.newNo Documentation 🚧
CubicOut.newNo Documentation 🚧
Elastic.newNo Documentation 🚧
ElasticIn.newNo Documentation 🚧
ElasticInOut.newNo Documentation 🚧
ElasticOut.newNo Documentation 🚧
ExponentialIn.newNo Documentation 🚧
ExponentialInOut.newNo Documentation 🚧
ExponentialOut.newNo Documentation 🚧
Linear.newNo Documentation 🚧
QuadraticIn.newNo Documentation 🚧
QuadraticInOut.newNo Documentation 🚧
QuadraticOut.newNo Documentation 🚧
QuarticIn.newNo Documentation 🚧
QuarticInOut.newNo Documentation 🚧
QuarticOut.newNo Documentation 🚧
QuinticIn.newNo Documentation 🚧
QuinticInOut.newNo Documentation 🚧
QuinticOut.newNo Documentation 🚧
SineIn.newNo Documentation 🚧
SineInOut.newNo Documentation 🚧
SineOut.newNo Documentation 🚧
SmoothStep.newNo Documentation 🚧
SmoothStepIn.newNo Documentation 🚧
SmoothStepOut.newNo Documentation 🚧
SmootherStep.newNo Documentation 🚧
SmootherStepIn.newNo Documentation 🚧
SmootherStepOut.newNo Documentation 🚧
Steps.newNo Documentation 🚧

sample

The eased value at t, clamped to between 0 and 1.

Arguments

NameTypeDocumentation
_selfEaseFunctionNo Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<EaseFunction>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceEaseFunctionThe constructed value.

BackIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BackIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

BackInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BackInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

BackOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BackOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

BounceIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BounceIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

BounceInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BounceInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

BounceOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::BounceOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CircularIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CircularIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CircularInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CircularInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CircularOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CircularOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CubicIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CubicIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CubicInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CubicInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

CubicOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::CubicOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

Elastic.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::Elastic>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ElasticIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ElasticIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ElasticInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ElasticInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ElasticOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ElasticOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ExponentialIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ExponentialIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ExponentialInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ExponentialInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

ExponentialOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::ExponentialOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

Linear.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::Linear>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuadraticIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuadraticIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuadraticInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuadraticInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuadraticOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuadraticOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuarticIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuarticIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuarticInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuarticInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuarticOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuarticOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuinticIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuinticIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuinticInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuinticInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

QuinticOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::QuinticOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SineIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SineIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SineInOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SineInOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SineOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SineOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmoothStep.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmoothStep>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmoothStepIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmoothStepIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmoothStepOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmoothStepOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmootherStep.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmootherStep>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmootherStepIn.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmootherStepIn>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

SmootherStepOut.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::SmootherStepOut>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

Steps.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EaseFunction::Steps>No Documentation 🚧

Returns

NameTypeDocumentation
returnEaseFunctionNo Documentation 🚧

Dir2

Dir2

  1. Vec2

Description

A normalized vector pointing in a direction in 2D space

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
neg_yThe direction along the negative y axis.
slerpSpherically interpolates between this direction and `other` by `t`, from 0 to 1.
yThe direction along the positive y axis.
eqWhether both directions have exactly the same components.
neg_xThe direction along the negative x axis.
newA unit direction pointing the same way as the vector, or nil if the vector is zero or not finite.
mulThis direction scaled by `length`, as a [`Vec2`](bevy_math::Vec2).
as_vec2This direction as a unit [`Vec2`](bevy_math::Vec2).
xThe direction along the positive x axis.
negThe opposite direction.

neg_y

The direction along the negative y axis.

Arguments

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

slerp

Spherically interpolates between this direction and other by t, from 0 to 1.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
otherDir2No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

y

The direction along the positive y axis.

Arguments

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

eq

Whether both directions have exactly the same components.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
otherDir2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

neg_x

The direction along the negative x axis.

Arguments

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

new

A unit direction pointing the same way as the vector, or nil if the vector is zero or not finite.

Arguments

NameTypeDocumentation
vVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Dir2>No Documentation 🚧

mul

This direction scaled by length, as a Vec2.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧
lengthF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

as_vec2

This direction as a unit Vec2.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

x

The direction along the positive x axis.

Arguments

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

neg

The opposite direction.

Arguments

NameTypeDocumentation
_selfDir2No Documentation 🚧

Returns

NameTypeDocumentation
returnDir2No Documentation 🚧

Dir3

Dir3

  1. Vec3

Description

A normalized vector pointing in a direction in 3D space

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
yThe direction along the positive y axis.
eqWhether both directions have exactly the same components.
neg_zThe direction along the negative z axis.
neg_yThe direction along the negative y axis.
slerpSpherically interpolates between this direction and `other` by `t`, from 0 to 1.
newA unit direction pointing the same way as the vector, or nil if the vector is zero or not finite.
mulThis direction scaled by `length`, as a [`Vec3`](bevy_math::Vec3).
as_vec3This direction as a unit [`Vec3`](bevy_math::Vec3).
zThe direction along the positive z axis.
negThe opposite direction.
neg_xThe direction along the negative x axis.
xThe direction along the positive x axis.

y

The direction along the positive y axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

eq

Whether both directions have exactly the same components.

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
otherDir3No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

neg_z

The direction along the negative z axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

neg_y

The direction along the negative y axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

slerp

Spherically interpolates between this direction and other by t, from 0 to 1.

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
otherDir3No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

new

A unit direction pointing the same way as the vector, or nil if the vector is zero or not finite.

Arguments

NameTypeDocumentation
vVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Dir3>No Documentation 🚧

mul

This direction scaled by length, as a Vec3.

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧
lengthF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

as_vec3

This direction as a unit Vec3.

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

z

The direction along the positive z axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

neg

The opposite direction.

Arguments

NameTypeDocumentation
_selfDir3No Documentation 🚧

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

neg_x

The direction along the negative x axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

x

The direction along the positive x axis.

Arguments

Returns

NameTypeDocumentation
returnDir3No Documentation 🚧

Rect

Rect

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in Rect::min and Rect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_cornersA rectangle spanning the two given corners, in either order.
eqWhether both rectangles have exactly the same corners.
half_sizeHalf of the full size of the rectangle as a [`Vec2`](bevy_math::Vec2).
containsWhether the point lies inside the rectangle, including its edges.
unionThe smallest rectangle that contains both this one and `other`.
inflateThis rectangle grown by `expansion` on every side, or shrunk if it is negative.
is_emptyWhether the rectangle has no area.
sizeThe full size of the rectangle as a [`Vec2`](bevy_math::Vec2).
centerThe center of the rectangle as a [`Vec2`](bevy_math::Vec2).
from_center_half_sizeA rectangle with the given center and half of its full size.
heightThe height of the rectangle.
newA rectangle from its minimum corner `(x0, y0)` and maximum corner `(x1, y1)`.
from_center_sizeA rectangle with the given center and full size.
widthThe width of the rectangle.
intersectThe overlap of this rectangle and `other`, which is empty if they do not overlap.

from_corners

A rectangle spanning the two given corners, in either order.

Arguments

NameTypeDocumentation
p0Vec2No Documentation 🚧
p1Vec2No Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

eq

Whether both rectangles have exactly the same corners.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

half_size

Half of the full size of the rectangle as a Vec2.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

contains

Whether the point lies inside the rectangle, including its edges.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

union

The smallest rectangle that contains both this one and other.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

inflate

This rectangle grown by expansion on every side, or shrunk if it is negative.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
expansionF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

is_empty

Whether the rectangle has no area.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

size

The full size of the rectangle as a Vec2.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

center

The center of the rectangle as a Vec2.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

from_center_half_size

A rectangle with the given center and half of its full size.

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
half_sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

height

The height of the rectangle.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

new

A rectangle from its minimum corner (x0, y0) and maximum corner (x1, y1).

Arguments

NameTypeDocumentation
x0F32No Documentation 🚧
y0F32No Documentation 🚧
x1F32No Documentation 🚧
y1F32No Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

from_center_size

A rectangle with the given center and full size.

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

width

The width of the rectangle.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

intersect

The overlap of this rectangle and other, which is empty if they do not overlap.

Arguments

NameTypeDocumentation
_selfRectNo Documentation 🚧
otherRectNo Documentation 🚧

Returns

NameTypeDocumentation
returnRectNo Documentation 🚧

Rot2

Rot2

Description

A 2D rotation.

Example

# use approx::assert_relative_eq;
# use bevy_math::{Rot2, Vec2};
use std::f32::consts::PI;

// Create rotations from counterclockwise angles in radians or degrees
let rotation1 = Rot2::radians(PI / 2.0);
let rotation2 = Rot2::degrees(45.0);

// Get the angle back as radians or degrees
assert_eq!(rotation1.as_degrees(), 90.0);
assert_eq!(rotation2.as_radians(), PI / 4.0);

// "Add" rotations together using `*`
#[cfg(feature = "approx")]
assert_relative_eq!(rotation1 * rotation2, Rot2::degrees(135.0));

// Rotate vectors
#[cfg(feature = "approx")]
assert_relative_eq!(rotation1 * Vec2::X, Vec2::Y);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
mulComposes two rotations when given a rotation, or rotates a [`Vec2`](bevy_math::Vec2) when given a vector.
degreesA counterclockwise rotation of `degrees` degrees.
identityThe rotation that leaves everything unchanged.
eqWhether both rotations have exactly the same components.
as_degreesThe angle of this rotation in degrees.
slerpSpherically interpolates between this rotation and `other` by `t`, from 0 to 1.
as_radiansThe angle of this rotation in radians.
nlerpLinearly interpolates between this rotation and `other` by `t`, from 0 to 1, then normalizes.
turn_fractionA counterclockwise rotation of `fraction` of a full turn, so `1.0` is a full turn.
inverseThe rotation that undoes this one.
radiansA counterclockwise rotation of `radians` radians.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

mul

Composes two rotations when given a rotation, or rotates a Vec2 when given a vector.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
rhsRot2Vec2

Returns

NameTypeDocumentation
returnRot2Vec2

degrees

A counterclockwise rotation of degrees degrees.

Arguments

NameTypeDocumentation
degreesF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

identity

The rotation that leaves everything unchanged.

Arguments

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

eq

Whether both rotations have exactly the same components.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

as_degrees

The angle of this rotation in degrees.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

slerp

Spherically interpolates between this rotation and other by t, from 0 to 1.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

as_radians

The angle of this rotation in radians.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

nlerp

Linearly interpolates between this rotation and other by t, from 0 to 1, then normalizes.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧
otherRot2No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

turn_fraction

A counterclockwise rotation of fraction of a full turn, so 1.0 is a full turn.

Arguments

NameTypeDocumentation
fractionF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

inverse

The rotation that undoes this one.

Arguments

NameTypeDocumentation
_selfRot2No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

radians

A counterclockwise rotation of radians radians.

Arguments

NameTypeDocumentation
radiansF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRot2No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Rot2>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRot2The constructed value.

Annulus

Annulus

Description

A primitive shape formed by the region between two circles, also known as a ring.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA ring with the given inner and outer radii.

new

A ring with the given inner and outer radii.

Arguments

NameTypeDocumentation
inner_radiusF32No Documentation 🚧
outer_radiusF32No Documentation 🚧

Returns

NameTypeDocumentation
returnAnnulusNo Documentation 🚧

Circle

Circle

Description

A circle primitive, representing the set of points some distance from the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA circle with the given radius.

new

A circle with the given radius.

Arguments

NameTypeDocumentation
radiusF32No Documentation 🚧

Returns

NameTypeDocumentation
returnCircleNo Documentation 🚧

Rectangle

Rectangle

Description

A rectangle primitive, which is like a square, except that the width and height can be different

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_sizeA rectangle with the given size as a [`Vec2`](bevy_math::Vec2).
newA rectangle with the given width and height.

from_size

A rectangle with the given size as a Vec2.

Arguments

NameTypeDocumentation
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnRectangleNo Documentation 🚧

new

A rectangle with the given width and height.

Arguments

NameTypeDocumentation
widthF32No Documentation 🚧
heightF32No Documentation 🚧

Returns

NameTypeDocumentation
returnRectangleNo Documentation 🚧

RegularPolygon

RegularPolygon

Description

A polygon centered on the origin where all vertices lie on a circle, equally far apart.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA regular polygon with the given number of sides, all corners at `circumradius` from the center.

new

A regular polygon with the given number of sides, all corners at circumradius from the center.

Arguments

NameTypeDocumentation
circumradiusF32No Documentation 🚧
sidesU32No Documentation 🚧

Returns

NameTypeDocumentation
returnRegularPolygonNo Documentation 🚧

Capsule3d

Capsule3d

Description

A 3D capsule primitive centered on the origin A three-dimensional capsule is defined as a surface at a distance (radius) from a line

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA capsule with the given radius and length of its middle section.

new

A capsule with the given radius and length of its middle section.

Arguments

NameTypeDocumentation
radiusF32No Documentation 🚧
lengthF32No Documentation 🚧

Returns

NameTypeDocumentation
returnCapsule3dNo Documentation 🚧

Cuboid

Cuboid

Description

A cuboid primitive, which is like a cube, except that the x, y, and z dimensions are not required to be the same.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_sizeA box with the given size as a [`Vec3`](bevy_math::Vec3).
newA box with the given length along the x, y and z axes.

from_size

A box with the given size as a Vec3.

Arguments

NameTypeDocumentation
sizeVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnCuboidNo Documentation 🚧

new

A box with the given length along the x, y and z axes.

Arguments

NameTypeDocumentation
x_lengthF32No Documentation 🚧
y_lengthF32No Documentation 🚧
z_lengthF32No Documentation 🚧

Returns

NameTypeDocumentation
returnCuboidNo Documentation 🚧

Cylinder

Cylinder

Description

A cylinder primitive centered on the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA cylinder with the given radius and height.

new

A cylinder with the given radius and height.

Arguments

NameTypeDocumentation
radiusF32No Documentation 🚧
heightF32No Documentation 🚧

Returns

NameTypeDocumentation
returnCylinderNo Documentation 🚧

Plane3d

Plane3d

Description

A bounded plane in 3D space. It forms a surface starting from the origin with a defined height and width.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA plane facing `normal` with the given half size. Errors if the normal is zero or not finite.

new

A plane facing normal with the given half size. Errors if the normal is zero or not finite.

Arguments

NameTypeDocumentation
normalVec3No Documentation 🚧
half_sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnPlane3dNo Documentation 🚧

Sphere

Sphere

Description

A sphere primitive, representing the set of all points some distance from the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA sphere with the given radius.

new

A sphere with the given radius.

Arguments

NameTypeDocumentation
radiusF32No Documentation 🚧

Returns

NameTypeDocumentation
returnSphereNo Documentation 🚧

Torus

Torus

  • minor_radius:F32
  • major_radius:F32

Description

A torus primitive, often representing a ring or donut shape The set of points some distance from a circle centered at the origin

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA donut shape with the given inner and outer radii of its tube.

new

A donut shape with the given inner and outer radii of its tube.

Arguments

NameTypeDocumentation
inner_radiusF32No Documentation 🚧
outer_radiusF32No Documentation 🚧

Returns

NameTypeDocumentation
returnTorusNo Documentation 🚧

Ray2d

Ray2d

Description

An infinite half-line starting at origin and going in direction in 2D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA ray from `origin` in the direction of `direction`. Errors if the direction is zero or not finite.
intersect_planeThe distance along the ray to the line through `plane_origin` with normal `plane_normal`, or nil if ...
get_pointThe point at `distance` along the ray from its origin.

new

A ray from origin in the direction of direction. Errors if the direction is zero or not finite.

Arguments

NameTypeDocumentation
originVec2No Documentation 🚧
directionVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnRay2dNo Documentation 🚧

intersect_plane

The distance along the ray to the line through plane_origin with normal plane_normal, or nil if the ray never reaches it. Errors if the normal is zero or not finite.

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧
plane_originVec2No Documentation 🚧
plane_normalVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<F32>No Documentation 🚧

get_point

The point at distance along the ray from its origin.

Arguments

NameTypeDocumentation
_selfRay2dNo Documentation 🚧
distanceF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

Ray3d

Ray3d

Description

An infinite half-line starting at origin and going in direction in 3D space.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newA ray from `origin` in the direction of `direction`. Errors if the direction is zero or not finite.
intersect_planeThe distance along the ray to the plane through `plane_origin` with normal `plane_normal`, or nil if...
get_pointThe point at `distance` along the ray from its origin.

new

A ray from origin in the direction of direction. Errors if the direction is zero or not finite.

Arguments

NameTypeDocumentation
originVec3No Documentation 🚧
directionVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnRay3dNo Documentation 🚧

intersect_plane

The distance along the ray to the plane through plane_origin with normal plane_normal, or nil if the ray never reaches it. Errors if the normal is zero or not finite.

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧
plane_originVec3No Documentation 🚧
plane_normalVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<F32>No Documentation 🚧

get_point

The point at distance along the ray from its origin.

Arguments

NameTypeDocumentation
_selfRay3dNo Documentation 🚧
distanceF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

DVec2

DVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_vec2Converts to a single precision [`Vec2`](bevy_math::Vec2).
newCreates a new double precision vector.

as_vec2

Converts to a single precision Vec2.

Arguments

NameTypeDocumentation
_selfDVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

new

Creates a new double precision vector.

Arguments

NameTypeDocumentation
xF64No Documentation 🚧
yF64No Documentation 🚧

Returns

NameTypeDocumentation
returnDVec2No Documentation 🚧

DVec3

DVec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_vec3Converts to a single precision [`Vec3`](bevy_math::Vec3).
newCreates a new double precision vector.

as_vec3

Converts to a single precision Vec3.

Arguments

NameTypeDocumentation
_selfDVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

new

Creates a new double precision vector.

Arguments

NameTypeDocumentation
xF64No Documentation 🚧
yF64No Documentation 🚧
zF64No Documentation 🚧

Returns

NameTypeDocumentation
returnDVec3No Documentation 🚧

IVec2

IVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
clampClamps every component between the components of `min` and `max`.
negNegates every component.
maxThe larger of each pair of components.
unit_xThe unit vector along the x axis.
remThe component-wise remainder of dividing by a vector, or by a number. Errors if any divisor componen...
splatA vector with all components set to `v`.
min_elementThe smallest component.
divDivides component-wise by a vector, or by a number. Errors if any divisor component is `0`.
newCreates a new vector.
to_arrayThe components as a list.
max_elementThe largest component.
as_vec2Converts to a float vector.
addAdds a vector or a number to every component.
eqWhether all components are equal.
zeroA vector with all components set to `0`.
mulMultiplies component-wise by a vector, or scales by a number.
subSubtracts a vector or a number from every component.
minThe smaller of each pair of components.
unit_yThe unit vector along the y axis.
dotThe dot product of two vectors.
absThe absolute value of every component.
oneA vector with all components set to `1`.
length_squaredThe squared length of the vector.

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
minIVec2No Documentation 🚧
maxIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

neg

Negates every component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2I32

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vI32No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

div

Divides component-wise by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2I32

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xI32No Documentation 🚧
yI32No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<I32>No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

as_vec2

Converts to a float vector.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2I32

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2I32

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
rhsIVec2I32

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

unit_y

The unit vector along the y axis.

Arguments

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧
otherIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

abs

The absolute value of every component.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

length_squared

The squared length of the vector.

Arguments

NameTypeDocumentation
_selfIVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

IVec3

IVec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
remThe component-wise remainder of dividing by a vector, or by a number. Errors if any divisor componen...
absThe absolute value of every component.
minThe smaller of each pair of components.
unit_yThe unit vector along the y axis.
newCreates a new vector.
length_squaredThe squared length of the vector.
to_arrayThe components as a list.
max_elementThe largest component.
unit_xThe unit vector along the x axis.
maxThe larger of each pair of components.
dotThe dot product of two vectors.
subSubtracts a vector or a number from every component.
min_elementThe smallest component.
as_vec3Converts to a float vector.
mulMultiplies component-wise by a vector, or scales by a number.
eqWhether all components are equal.
unit_zThe unit vector along the z axis.
negNegates every component.
clampClamps every component between the components of `min` and `max`.
zeroA vector with all components set to `0`.
divDivides component-wise by a vector, or by a number. Errors if any divisor component is `0`.
addAdds a vector or a number to every component.
splatA vector with all components set to `v`.
oneA vector with all components set to `1`.

rem

The component-wise remainder of dividing by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3I32

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

abs

The absolute value of every component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
otherIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

unit_y

The unit vector along the y axis.

Arguments

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xI32No Documentation 🚧
yI32No Documentation 🚧
zI32No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

length_squared

The squared length of the vector.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<I32>No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
otherIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
otherIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3I32

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnI32No Documentation 🚧

as_vec3

Converts to a float vector.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3I32

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
otherIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

unit_z

The unit vector along the z axis.

Arguments

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

neg

Negates every component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
minIVec3No Documentation 🚧
maxIVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

div

Divides component-wise by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3I32

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfIVec3No Documentation 🚧
rhsIVec3I32

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vI32No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

Mat3

Mat3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_diagonalA matrix with the given diagonal and zeros elsewhere.
transposeThe matrix with rows and columns swapped.
from_colsA matrix with the given columns.
from_rotation_zA rotation matrix of `angle` radians around the z axis.
addAdds two matrices component-wise.
determinantThe determinant of the matrix.
from_rotation_yA rotation matrix of `angle` radians around the y axis.
transform_vector2Transforms a direction in 2D, ignoring translation.
divDivides every component by a number.
from_rotation_xA rotation matrix of `angle` radians around the x axis.
colThe column at `index`, starting from `0`. Errors if `index` is out of range.
rowThe row at `index`, starting from `0`. Errors if `index` is out of range.
subSubtracts two matrices component-wise.
mul_vec3Transforms a [`Vec3`](bevy_math::Vec3) by this matrix.
from_quatThe rotation matrix of a rotation.
inverseThe matrix that undoes this one.
mulMultiplies by a matrix, or transforms a vector, or scales every component by a number.
identityThe identity matrix, which leaves vectors unchanged.
transform_point2Transforms a point in 2D, treating it as having a z of `1`.
eqWhether both matrices have exactly the same components.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

from_diagonal

A matrix with the given diagonal and zeros elsewhere.

Arguments

NameTypeDocumentation
diagonalVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

transpose

The matrix with rows and columns swapped.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

from_cols

A matrix with the given columns.

Arguments

NameTypeDocumentation
xVec3No Documentation 🚧
yVec3No Documentation 🚧
zVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

from_rotation_z

A rotation matrix of angle radians around the z axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

add

Adds two matrices component-wise.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
otherMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

determinant

The determinant of the matrix.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

from_rotation_y

A rotation matrix of angle radians around the y axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

transform_vector2

Transforms a direction in 2D, ignoring translation.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
vectorVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

div

Divides every component by a number.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

from_rotation_x

A rotation matrix of angle radians around the x axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

col

The column at index, starting from 0. Errors if index is out of range.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
indexUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

row

The row at index, starting from 0. Errors if index is out of range.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
indexUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

sub

Subtracts two matrices component-wise.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
otherMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

mul_vec3

Transforms a Vec3 by this matrix.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
vVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

from_quat

The rotation matrix of a rotation.

Arguments

NameTypeDocumentation
qQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

inverse

The matrix that undoes this one.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

mul

Multiplies by a matrix, or transforms a vector, or scales every component by a number.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
rhsMat3Vec3

Returns

NameTypeDocumentation
returnMat3Vec3

identity

The identity matrix, which leaves vectors unchanged.

Arguments

Returns

NameTypeDocumentation
returnMat3No Documentation 🚧

transform_point2

Transforms a point in 2D, treating it as having a z of 1.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
pointVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

eq

Whether both matrices have exactly the same components.

Arguments

NameTypeDocumentation
_selfMat3No Documentation 🚧
otherMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Mat3>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMat3The constructed value.

Mat4

Mat4

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
transposeThe matrix with rows and columns swapped.
rowThe row at `index`, starting from `0`. Errors if `index` is out of range.
addAdds two matrices component-wise.
inverseThe matrix that undoes this one.
from_scale_rotation_translationA matrix that scales by `scale`, then rotates by `rotation`, then moves by `translation`.
from_colsA matrix with the given columns.
transform_vector3Transforms a direction in 3D, ignoring translation.
identityThe identity matrix, which leaves vectors unchanged.
from_rotation_translationA matrix that rotates by `rotation`, then moves by `translation`.
transform_point3Transforms a point in 3D, including translation and the projection divide.
eqWhether both matrices have exactly the same components.
mulMultiplies by a matrix, or transforms a vector, or scales every component by a number.
divDivides every component by a number.
colThe column at `index`, starting from `0`. Errors if `index` is out of range.
from_scaleA matrix that scales every axis by the matching component of `scale`.
determinantThe determinant of the matrix.
from_quatThe rotation matrix of a rotation.
subSubtracts two matrices component-wise.
project_point3Transforms a point in 3D by a projection matrix, including the perspective divide.
from_translationA matrix that moves points by `translation`.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

transpose

The matrix with rows and columns swapped.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

row

The row at index, starting from 0. Errors if index is out of range.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
indexUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

add

Adds two matrices component-wise.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
otherMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

inverse

The matrix that undoes this one.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

from_scale_rotation_translation

A matrix that scales by scale, then rotates by rotation, then moves by translation.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

from_cols

A matrix with the given columns.

Arguments

NameTypeDocumentation
xVec4No Documentation 🚧
yVec4No Documentation 🚧
zVec4No Documentation 🚧
wVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

transform_vector3

Transforms a direction in 3D, ignoring translation.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
vectorVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

identity

The identity matrix, which leaves vectors unchanged.

Arguments

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

from_rotation_translation

A matrix that rotates by rotation, then moves by translation.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

transform_point3

Transforms a point in 3D, including translation and the projection divide.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

eq

Whether both matrices have exactly the same components.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
otherMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

mul

Multiplies by a matrix, or transforms a vector, or scales every component by a number.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsMat4Vec4

Returns

NameTypeDocumentation
returnMat4Vec4

div

Divides every component by a number.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
rhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

col

The column at index, starting from 0. Errors if index is out of range.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
indexUsizeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

from_scale

A matrix that scales every axis by the matching component of scale.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

determinant

The determinant of the matrix.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

from_quat

The rotation matrix of a rotation.

Arguments

NameTypeDocumentation
qQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

sub

Subtracts two matrices component-wise.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
otherMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

project_point3

Transforms a point in 3D by a projection matrix, including the perspective divide.

Arguments

NameTypeDocumentation
_selfMat4No Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

from_translation

A matrix that moves points by translation.

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Mat4>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMat4The constructed value.

Quat

Quat

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
xyzThe vector part of the quaternion, i.e. the x, y and z components.
from_mat3The rotation described by a 3x3 rotation matrix.
lengthThe length of the quaternion, which is `1` for a rotation.
from_axis_angleA rotation of `angle` radians around `axis`. Errors if the axis is zero or not finite.
from_rotation_zA rotation of `angle` radians around the z axis.
eqWhether both rotations have exactly the same components.
to_eulerThe three angles in radians of this rotation, in the given [`EulerRot`](bevy_math::EulerRot) order.
identityThe identity rotation, which leaves everything unchanged.
axisThe axis this rotation turns around.
angleThe angle in radians this rotation turns by around its [`axis`](Self::axis).
normalizeThe rotation scaled to a length of `1`.
slerpSpherically interpolates towards `other`, `t = 0` gives this rotation and `t = 1` gives `other`.
conjugateThe rotation with the vector part negated, which is the inverse for unit quaternions.
mul_vec3Rotates a [`Vec3`](bevy_math::Vec3).
is_normalizedWhether the quaternion has a length of `1`.
inverseThe rotation that undoes this one.
lerpLinearly interpolates towards `other`, `t = 0` gives this rotation and `t = 1` gives `other`.
negThe opposite rotation, with every component negated.
from_rotation_xA rotation of `angle` radians around the x axis.
dotThe dot product of two rotations.
angle_betweenThe angle in radians between two rotations.
from_rotation_yA rotation of `angle` radians around the y axis.
mulComposes two rotations when given a rotation, or rotates a vector when given a [`Vec3`](bevy_math::Vec3).
from_rotation_arcThe rotation that turns the direction `from` onto the direction `to`. Errors if either vector is zer...
from_eulerA rotation from three angles in radians, applied in the given [`EulerRot`](bevy_math::EulerRot) order, i.e. `EulerRot.YXZ`.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

xyz

The vector part of the quaternion, i.e. the x, y and z components.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

from_mat3

The rotation described by a 3x3 rotation matrix.

Arguments

NameTypeDocumentation
mMat3No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

length

The length of the quaternion, which is 1 for a rotation.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

from_axis_angle

A rotation of angle radians around axis. Errors if the axis is zero or not finite.

Arguments

NameTypeDocumentation
axisVec3No Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

from_rotation_z

A rotation of angle radians around the z axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

eq

Whether both rotations have exactly the same components.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
otherQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

to_euler

The three angles in radians of this rotation, in the given EulerRot order.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
orderEulerRotNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec<F32>No Documentation 🚧

identity

The identity rotation, which leaves everything unchanged.

Arguments

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

axis

The axis this rotation turns around.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

angle

The angle in radians this rotation turns by around its axis.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

normalize

The rotation scaled to a length of 1.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

slerp

Spherically interpolates towards other, t = 0 gives this rotation and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
otherQuatNo Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

conjugate

The rotation with the vector part negated, which is the inverse for unit quaternions.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

mul_vec3

Rotates a Vec3.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
vVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

is_normalized

Whether the quaternion has a length of 1.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

inverse

The rotation that undoes this one.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

lerp

Linearly interpolates towards other, t = 0 gives this rotation and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
otherQuatNo Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

neg

The opposite rotation, with every component negated.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

from_rotation_x

A rotation of angle radians around the x axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

dot

The dot product of two rotations.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
otherQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

angle_between

The angle in radians between two rotations.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
otherQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

from_rotation_y

A rotation of angle radians around the y axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

mul

Composes two rotations when given a rotation, or rotates a vector when given a Vec3.

Arguments

NameTypeDocumentation
_selfQuatNo Documentation 🚧
rhsQuatVec3

Returns

NameTypeDocumentation
returnQuatVec3

from_rotation_arc

The rotation that turns the direction from onto the direction to. Errors if either vector is zero or not finite.

Arguments

NameTypeDocumentation
fromVec3No Documentation 🚧
toVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

from_euler

A rotation from three angles in radians, applied in the given EulerRot order, i.e. EulerRot.YXZ.

Arguments

NameTypeDocumentation
orderEulerRotNo Documentation 🚧
aF32No Documentation 🚧
bF32No Documentation 🚧
cF32No Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Quat>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceQuatThe constructed value.

UVec2

UVec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
dotThe dot product of two vectors.
unit_yThe unit vector along the y axis.
addAdds a vector or a number to every component.
as_vec2Converts to a float vector.
maxThe larger of each pair of components.
to_arrayThe components as a list.
min_elementThe smallest component.
divDivides component-wise by a vector, or by a number. Errors if any divisor component is `0`.
splatA vector with all components set to `v`.
zeroA vector with all components set to `0`.
clampClamps every component between the components of `min` and `max`.
subSubtracts a vector or a number from every component.
remThe component-wise remainder of dividing by a vector, or by a number. Errors if any divisor componen...
oneA vector with all components set to `1`.
mulMultiplies component-wise by a vector, or scales by a number.
length_squaredThe squared length of the vector.
newCreates a new vector.
minThe smaller of each pair of components.
max_elementThe largest component.
unit_xThe unit vector along the x axis.
eqWhether all components are equal.

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

unit_y

The unit vector along the y axis.

Arguments

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2U32

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

as_vec2

Converts to a float vector.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<U32>No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

div

Divides component-wise by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2U32

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vU32No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
minUVec2No Documentation 🚧
maxUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2U32

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2U32

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
rhsUVec2U32

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

length_squared

The squared length of the vector.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xU32No Documentation 🚧
yU32No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfUVec2No Documentation 🚧
otherUVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

UVec3

UVec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_vec3Converts to a float vector.
length_squaredThe squared length of the vector.
newCreates a new vector.
clampClamps every component between the components of `min` and `max`.
zeroA vector with all components set to `0`.
addAdds a vector or a number to every component.
remThe component-wise remainder of dividing by a vector, or by a number. Errors if any divisor componen...
splatA vector with all components set to `v`.
unit_xThe unit vector along the x axis.
to_arrayThe components as a list.
min_elementThe smallest component.
minThe smaller of each pair of components.
mulMultiplies component-wise by a vector, or scales by a number.
subSubtracts a vector or a number from every component.
eqWhether all components are equal.
unit_zThe unit vector along the z axis.
dotThe dot product of two vectors.
maxThe larger of each pair of components.
divDivides component-wise by a vector, or by a number. Errors if any divisor component is `0`.
oneA vector with all components set to `1`.
unit_yThe unit vector along the y axis.
max_elementThe largest component.

as_vec3

Converts to a float vector.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

length_squared

The squared length of the vector.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xU32No Documentation 🚧
yU32No Documentation 🚧
zU32No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
minUVec3No Documentation 🚧
maxUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3U32

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3U32

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vU32No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<U32>No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
otherUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3U32

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3U32

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
otherUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

unit_z

The unit vector along the z axis.

Arguments

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
otherUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
otherUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

div

Divides component-wise by a vector, or by a number. Errors if any divisor component is 0.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧
rhsUVec3U32

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

unit_y

The unit vector along the y axis.

Arguments

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfUVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

Vec2

Vec2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
unit_xThe unit vector along the x axis.
newCreates a new vector. ```multi-lang-example,lua local Vec2 = import_namespace(“math”).Vec2 local v = Vec2.new(3, 4) assert(v:length() == 5) ``` ```multi-lang-example,rune let Vec2 = import_...
rdivDivides a number by every component, for `n / v`.
to_angleThe angle of this vector in radians, measured counterclockwise from the x axis.
absThe absolute value of every component.
project_ontoThe projection of this vector onto `other`.
reflectReflects this vector off a surface with the given `normal`, which must be of length `1`.
as_dvec2Converts to a double precision vector.
dotThe dot product of two vectors.
clamp_lengthScales the vector so that its length is between `min` and `max`.
floorRounds every component down.
lengthThe length of the vector.
as_uvec2Converts to an unsigned integer vector, rounding towards zero, negative values become `0`.
zeroA vector with all components set to `0`.
distanceThe distance between two points.
addAdds a vector or a number to every component.
roundRounds every component to the nearest integer.
try_normalizeThe vector scaled to a length of `1`, or nil if that’s not possible.
reject_fromThe part of this vector perpendicular to `other`.
perpThe vector rotated by 90 degrees counterclockwise.
normalize_or_zeroThe vector scaled to a length of `1`, or zero if that’s not possible.
subSubtracts a vector or a number from every component.
max_elementThe largest component.
splatA vector with all components set to `v`.
extendA [`Vec3`](bevy_math::Vec3) with the given `z`.
divDivides component-wise by a vector, or by a number.
from_angleThe unit vector of the given angle in radians, measured counterclockwise from the x axis.
unit_yThe unit vector along the y axis.
minThe smaller of each pair of components.
length_squaredThe squared length of the vector, faster than [`length`](Self::length) when comparing lengths.
distance_squaredThe squared distance between two points.
min_elementThe smallest component.
angle_toThe signed angle in radians to rotate this vector onto `other`.
rsubSubtracts every component from a number, for `n - v`.
mulMultiplies component-wise by a vector, or scales by a number.
lerpLinearly interpolates towards `other`, `t = 0` gives this vector and `t = 1` gives `other`.
ceilRounds every component up.
negNegates every component.
clampClamps every component between the components of `min` and `max`.
perp_dotThe 2D cross product, positive if `other` is counterclockwise from this vector.
maxThe larger of each pair of components.
signumThe sign of every component: `1`, `-1`, or NaN.
clamp_length_maxScales the vector down so that its length is at most `max`.
oneA vector with all components set to `1`.
as_ivec2Converts to an integer vector, rounding towards zero.
remThe component-wise remainder of dividing by a vector, or by a number.
move_towardsMoves towards `target` by at most `max_distance`, without overshooting.
rotateRotates `other` by the angle of this vector, and scales it by its length.
fractThe fractional part of every component, i.e. `x - floor(x)`.
to_arrayThe components as a list.
eqWhether all components are equal.
normalizeThe vector scaled to a length of `1`. Errors if the vector is zero, or not finite.

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

new

Creates a new vector.

local Vec2 = import_namespace("math").Vec2
local v = Vec2.new(3, 4)
assert(v:length() == 5)
let Vec2 = import_namespace("math").Vec2;
let v = Vec2.new(3.0, 4.0);
assert!(v.length() == 5.0);

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

rdiv

Divides a number by every component, for n / v.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

to_angle

The angle of this vector in radians, measured counterclockwise from the x axis.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

abs

The absolute value of every component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

project_onto

The projection of this vector onto other.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

reflect

Reflects this vector off a surface with the given normal, which must be of length 1.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
normalVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

as_dvec2

Converts to a double precision vector.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnDVec2No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

clamp_length

Scales the vector so that its length is between min and max.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
minF32No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

floor

Rounds every component down.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

length

The length of the vector.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

as_uvec2

Converts to an unsigned integer vector, rounding towards zero, negative values become 0.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

distance

The distance between two points.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2F32

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

round

Rounds every component to the nearest integer.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

try_normalize

The vector scaled to a length of 1, or nil if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec2>No Documentation 🚧

reject_from

The part of this vector perpendicular to other.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

perp

The vector rotated by 90 degrees counterclockwise.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

normalize_or_zero

The vector scaled to a length of 1, or zero if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2F32

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

extend

A Vec3 with the given z.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
zF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

div

Divides component-wise by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2F32

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

from_angle

The unit vector of the given angle in radians, measured counterclockwise from the x axis.

Arguments

NameTypeDocumentation
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

unit_y

The unit vector along the y axis.

Arguments

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

length_squared

The squared length of the vector, faster than length when comparing lengths.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

distance_squared

The squared distance between two points.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

angle_to

The signed angle in radians to rotate this vector onto other.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

rsub

Subtracts every component from a number, for n - v.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2F32

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

lerp

Linearly interpolates towards other, t = 0 gives this vector and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

ceil

Rounds every component up.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

neg

Negates every component.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
minVec2No Documentation 🚧
maxVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

perp_dot

The 2D cross product, positive if other is counterclockwise from this vector.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

signum

The sign of every component: 1, -1, or NaN.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

clamp_length_max

Scales the vector down so that its length is at most max.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

as_ivec2

Converts to an integer vector, rounding towards zero.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec2No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
rhsVec2F32

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

move_towards

Moves towards target by at most max_distance, without overshooting.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
targetVec2No Documentation 🚧
max_distanceF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

rotate

Rotates other by the angle of this vector, and scales it by its length.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

fract

The fractional part of every component, i.e. x - floor(x).

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<F32>No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧
otherVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

normalize

The vector scaled to a length of 1. Errors if the vector is zero, or not finite.

Arguments

NameTypeDocumentation
_selfVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

Vec3

Vec3

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
zeroA vector with all components set to `0`.
normalize_or_zeroThe vector scaled to a length of `1`, or zero if that’s not possible.
eqWhether all components are equal.
clamp_length_maxScales the vector down so that its length is at most `max`.
crossThe cross product, perpendicular to both vectors.
minThe smaller of each pair of components.
reflectReflects this vector off a surface with the given `normal`, which must be of length `1`.
unit_xThe unit vector along the x axis.
to_vec3aConverts to a [`Vec3A`](bevy_math::Vec3A), used by some bevy types such as bounding boxes.
normalizeThe vector scaled to a length of `1`. Errors if the vector is zero, or not finite.
move_towardsMoves towards `target` by at most `max_distance`, without overshooting.
reject_fromThe part of this vector perpendicular to `other`.
absThe absolute value of every component.
dotThe dot product of two vectors.
roundRounds every component to the nearest integer.
splatA vector with all components set to `v`.
clampClamps every component between the components of `min` and `max`.
unit_yThe unit vector along the y axis, which is up in bevy.
extendA [`Vec4`](bevy_math::Vec4) with the given `w`.
any_orthogonal_vectorSome vector perpendicular to this one.
min_elementThe smallest component.
floorRounds every component down.
signumThe sign of every component: `1`, `-1`, or NaN.
as_uvec3Converts to an unsigned integer vector, rounding towards zero, negative values become `0`.
as_dvec3Converts to a double precision vector.
try_normalizeThe vector scaled to a length of `1`, or nil if that’s not possible.
truncateA [`Vec2`](bevy_math::Vec2) of the `x` and `y` components.
lengthThe length of the vector.
ceilRounds every component up.
divDivides component-wise by a vector, or by a number.
length_squaredThe squared length of the vector, faster than [`length`](Self::length) when comparing lengths.
angle_betweenThe angle in radians between two vectors, between `0` and `pi`.
distance_squaredThe squared distance between two points.
newCreates a new vector. ```multi-lang-example,lua local Vec3 = import_namespace(“math”).Vec3 local v = Vec3.new(1, 2, 3) assert(v + v == Vec3.new(2, 4, 6)) ``` ```multi-lang-example,rune let Vec3 = import_...
fractThe fractional part of every component, i.e. `x - floor(x)`.
to_arrayThe components as a list.
max_elementThe largest component.
addAdds a vector or a number to every component.
oneA vector with all components set to `1`.
negNegates every component.
as_ivec3Converts to an integer vector, rounding towards zero.
rdivDivides a number by every component, for `n / v`.
mulMultiplies component-wise by a vector, or scales by a number.
project_ontoThe projection of this vector onto `other`.
remThe component-wise remainder of dividing by a vector, or by a number.
maxThe larger of each pair of components.
unit_zThe unit vector along the z axis.
subSubtracts a vector or a number from every component.
distanceThe distance between two points.
rsubSubtracts every component from a number, for `n - v`.
clamp_lengthScales the vector so that its length is between `min` and `max`.
lerpLinearly interpolates towards `other`, `t = 0` gives this vector and `t = 1` gives `other`.

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

normalize_or_zero

The vector scaled to a length of 1, or zero if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

clamp_length_max

Scales the vector down so that its length is at most max.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

cross

The cross product, perpendicular to both vectors.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

reflect

Reflects this vector off a surface with the given normal, which must be of length 1.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
normalVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

unit_x

The unit vector along the x axis.

Arguments

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

to_vec3a

Converts to a Vec3A, used by some bevy types such as bounding boxes.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3ANo Documentation 🚧

normalize

The vector scaled to a length of 1. Errors if the vector is zero, or not finite.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

move_towards

Moves towards target by at most max_distance, without overshooting.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
targetVec3No Documentation 🚧
max_distanceF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

reject_from

The part of this vector perpendicular to other.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

abs

The absolute value of every component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

round

Rounds every component to the nearest integer.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
minVec3No Documentation 🚧
maxVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

unit_y

The unit vector along the y axis, which is up in bevy.

Arguments

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

extend

A Vec4 with the given w.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
wF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

any_orthogonal_vector

Some vector perpendicular to this one.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

floor

Rounds every component down.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

signum

The sign of every component: 1, -1, or NaN.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

as_uvec3

Converts to an unsigned integer vector, rounding towards zero, negative values become 0.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnUVec3No Documentation 🚧

as_dvec3

Converts to a double precision vector.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnDVec3No Documentation 🚧

try_normalize

The vector scaled to a length of 1, or nil if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec3>No Documentation 🚧

truncate

A Vec2 of the x and y components.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

length

The length of the vector.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

ceil

Rounds every component up.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

div

Divides component-wise by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3F32

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

length_squared

The squared length of the vector, faster than length when comparing lengths.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

angle_between

The angle in radians between two vectors, between 0 and pi.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

distance_squared

The squared distance between two points.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

new

Creates a new vector.

local Vec3 = import_namespace("math").Vec3
local v = Vec3.new(1, 2, 3)
assert(v + v == Vec3.new(2, 4, 6))
let Vec3 = import_namespace("math").Vec3;
let v = Vec3.new(1.0, 2.0, 3.0);
assert!(v + v == Vec3.new(2.0, 4.0, 6.0));

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧
zF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

fract

The fractional part of every component, i.e. x - floor(x).

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<F32>No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3F32

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

neg

Negates every component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

as_ivec3

Converts to an integer vector, rounding towards zero.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnIVec3No Documentation 🚧

rdiv

Divides a number by every component, for n / v.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3F32

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

project_onto

The projection of this vector onto other.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3F32

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

unit_z

The unit vector along the z axis.

Arguments

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
rhsVec3F32

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

distance

The distance between two points.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

rsub

Subtracts every component from a number, for n - v.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

clamp_length

Scales the vector so that its length is between min and max.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
minF32No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

lerp

Linearly interpolates towards other, t = 0 gives this vector and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfVec3No Documentation 🚧
otherVec3No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

Vec3A

Vec3A

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new vector.
to_vec3Converts to a [`Vec3`](bevy_math::Vec3).

new

Creates a new vector.

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧
zF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3ANo Documentation 🚧

to_vec3

Converts to a Vec3.

Arguments

NameTypeDocumentation
_selfVec3ANo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

Vec4

Vec4

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
length_squaredThe squared length of the vector, faster than [`length`](Self::length) when comparing lengths.
distance_squaredThe squared distance between two points.
rsubSubtracts every component from a number, for `n - v`.
signumThe sign of every component: `1`, `-1`, or NaN.
clampClamps every component between the components of `min` and `max`.
reflectReflects this vector off a surface with the given `normal`, which must be of length `1`.
clamp_length_maxScales the vector down so that its length is at most `max`.
normalizeThe vector scaled to a length of `1`. Errors if the vector is zero, or not finite.
floorRounds every component down.
to_arrayThe components as a list.
addAdds a vector or a number to every component.
maxThe larger of each pair of components.
zeroA vector with all components set to `0`.
fractThe fractional part of every component, i.e. `x - floor(x)`.
min_elementThe smallest component.
divDivides component-wise by a vector, or by a number.
minThe smaller of each pair of components.
negNegates every component.
dotThe dot product of two vectors.
rdivDivides a number by every component, for `n / v`.
truncateA [`Vec3`](bevy_math::Vec3) of the `x`, `y` and `z` components.
subSubtracts a vector or a number from every component.
newCreates a new vector.
lerpLinearly interpolates towards `other`, `t = 0` gives this vector and `t = 1` gives `other`.
ceilRounds every component up.
eqWhether all components are equal.
absThe absolute value of every component.
reject_fromThe part of this vector perpendicular to `other`.
try_normalizeThe vector scaled to a length of `1`, or nil if that’s not possible.
oneA vector with all components set to `1`.
splatA vector with all components set to `v`.
clamp_lengthScales the vector so that its length is between `min` and `max`.
move_towardsMoves towards `target` by at most `max_distance`, without overshooting.
distanceThe distance between two points.
project_ontoThe projection of this vector onto `other`.
mulMultiplies component-wise by a vector, or scales by a number.
normalize_or_zeroThe vector scaled to a length of `1`, or zero if that’s not possible.
roundRounds every component to the nearest integer.
max_elementThe largest component.
lengthThe length of the vector.
remThe component-wise remainder of dividing by a vector, or by a number.

length_squared

The squared length of the vector, faster than length when comparing lengths.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

distance_squared

The squared distance between two points.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

rsub

Subtracts every component from a number, for n - v.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

signum

The sign of every component: 1, -1, or NaN.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

clamp

Clamps every component between the components of min and max.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
minVec4No Documentation 🚧
maxVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

reflect

Reflects this vector off a surface with the given normal, which must be of length 1.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
normalVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

clamp_length_max

Scales the vector down so that its length is at most max.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

normalize

The vector scaled to a length of 1. Errors if the vector is zero, or not finite.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

floor

Rounds every component down.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

to_array

The components as a list.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec<F32>No Documentation 🚧

add

Adds a vector or a number to every component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4F32

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

max

The larger of each pair of components.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

zero

A vector with all components set to 0.

Arguments

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

fract

The fractional part of every component, i.e. x - floor(x).

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

min_element

The smallest component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

div

Divides component-wise by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4F32

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

min

The smaller of each pair of components.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

neg

Negates every component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

dot

The dot product of two vectors.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

rdiv

Divides a number by every component, for n / v.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
lhsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

truncate

A Vec3 of the x, y and z components.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

sub

Subtracts a vector or a number from every component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4F32

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

new

Creates a new vector.

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧
zF32No Documentation 🚧
wF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

lerp

Linearly interpolates towards other, t = 0 gives this vector and t = 1 gives other.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧
tF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

ceil

Rounds every component up.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

eq

Whether all components are equal.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

abs

The absolute value of every component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

reject_from

The part of this vector perpendicular to other.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

try_normalize

The vector scaled to a length of 1, or nil if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec4>No Documentation 🚧

one

A vector with all components set to 1.

Arguments

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

splat

A vector with all components set to v.

Arguments

NameTypeDocumentation
vF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

clamp_length

Scales the vector so that its length is between min and max.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
minF32No Documentation 🚧
maxF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

move_towards

Moves towards target by at most max_distance, without overshooting.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
targetVec4No Documentation 🚧
max_distanceF32No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

distance

The distance between two points.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

project_onto

The projection of this vector onto other.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
otherVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

mul

Multiplies component-wise by a vector, or scales by a number.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4F32

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

normalize_or_zero

The vector scaled to a length of 1, or zero if that’s not possible.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

round

Rounds every component to the nearest integer.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

max_element

The largest component.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

length

The length of the vector.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

rem

The component-wise remainder of dividing by a vector, or by a number.

Arguments

NameTypeDocumentation
_selfVec4No Documentation 🚧
rhsVec4F32

Returns

NameTypeDocumentation
returnVec4No Documentation 🚧

JumpAt

Start

End

None

Both

Description

Configuration options for the [EaseFunction::Steps] curves. This closely replicates the CSS step function specification.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Both.newNo Documentation 🚧
End.newNo Documentation 🚧
None.newNo Documentation 🚧
Start.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JumpAt>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJumpAtThe constructed value.

Both.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JumpAt::Both>No Documentation 🚧

Returns

NameTypeDocumentation
returnJumpAtNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JumpAt::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnJumpAtNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JumpAt::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnJumpAtNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JumpAt::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnJumpAtNo Documentation 🚧

CompassOctant

North

NorthEast

East

SouthEast

South

SouthWest

West

NorthWest

Description

A compass enum with 8 directions.

         N (North)
         ▲
    NW   │   NE
       ╲ │ ╱
W (West) ┼─────► E (East)
       ╱ │ ╲
    SW   │   SE
         ▼
         S (South)

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
East.newNo Documentation 🚧
North.newNo Documentation 🚧
NorthEast.newNo Documentation 🚧
NorthWest.newNo Documentation 🚧
South.newNo Documentation 🚧
SouthEast.newNo Documentation 🚧
SouthWest.newNo Documentation 🚧
West.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<CompassOctant>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCompassOctantThe constructed value.

East.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::East>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

North.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::North>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

NorthEast.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::NorthEast>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

NorthWest.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::NorthWest>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

South.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::South>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

SouthEast.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::SouthEast>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

SouthWest.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::SouthWest>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

West.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompassOctant::West>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompassOctantNo Documentation 🚧

URect

URect

Description

A rectangle defined by two opposite corners.

The rectangle is axis aligned, and defined by its minimum and maximum coordinates, stored in URect::min and URect::max, respectively. The minimum/maximum invariant must be upheld by the user when directly assigning the fields, otherwise some methods produce invalid results. It is generally recommended to use one of the constructor methods instead, which will ensure this invariant is met, unless you already have the minimum and maximum corners.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<URect>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceURectThe constructed value.

Aabb2d

Aabb2d

Description

A 2D axis-aligned bounding box, or bounding rectangle

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Aabb2d>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAabb2dThe constructed value.

Aabb3d

Aabb3d

Description

A 3D axis-aligned bounding box

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Aabb3d>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAabb3dThe constructed value.

Affine2

Affine2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Affine2>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAffine2The constructed value.

Affine3A

Affine3A

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Affine3A>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAffine3AThe constructed value.

EulerRot

ZYX

ZXY

YXZ

YZX

XYZ

XZY

ZYZ

ZXZ

YXY

YZY

XYX

XZX

ZYXEx

ZXYEx

YXZEx

YZXEx

XYZEx

XZYEx

ZYZEx

ZXZEx

YXYEx

YZYEx

XYXEx

XZXEx

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
XYX.newNo Documentation 🚧
XYXEx.newNo Documentation 🚧
XYZ.newNo Documentation 🚧
XYZEx.newNo Documentation 🚧
XZX.newNo Documentation 🚧
XZXEx.newNo Documentation 🚧
XZY.newNo Documentation 🚧
XZYEx.newNo Documentation 🚧
YXY.newNo Documentation 🚧
YXYEx.newNo Documentation 🚧
YXZ.newNo Documentation 🚧
YXZEx.newNo Documentation 🚧
YZX.newNo Documentation 🚧
YZXEx.newNo Documentation 🚧
YZY.newNo Documentation 🚧
YZYEx.newNo Documentation 🚧
ZXY.newNo Documentation 🚧
ZXYEx.newNo Documentation 🚧
ZXZ.newNo Documentation 🚧
ZXZEx.newNo Documentation 🚧
ZYX.newNo Documentation 🚧
ZYXEx.newNo Documentation 🚧
ZYZ.newNo Documentation 🚧
ZYZEx.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<EulerRot>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceEulerRotThe constructed value.

XYX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XYX>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XYXEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XYXEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XYZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XYZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XYZEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XYZEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XZX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XZX>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XZXEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XZXEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XZY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XZY>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

XZYEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::XZYEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YXY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YXY>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YXYEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YXYEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YXZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YXZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YXZEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YXZEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YZX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YZX>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YZXEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YZXEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YZY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YZY>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

YZYEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::YZYEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZXY.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZXY>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZXYEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZXYEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZXZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZXZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZXZEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZXZEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZYX.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZYX>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZYXEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZYXEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZYZ.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZYZ>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

ZYZEx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<EulerRot::ZYZEx>No Documentation 🚧

Returns

NameTypeDocumentation
returnEulerRotNo Documentation 🚧

Mat2

Mat2

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Mat2>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMat2The constructed value.

Mat3A

Mat3A

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Mat3A>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMat3AThe constructed value.

petgraph

The types and functions in the petgraph namespace, as returned by import_namespace("petgraph").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
DiGraph<Unknown, Unknown, U32>No Documentation 🚧

DiGraph<TypeId(0x53d7cc6723a82604a5425ebd39f46af7), (), U32>

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<DiGraph<TypeId(0x53d7cc6723a82604a5425ebd39f46af7), (), U32>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDiGraph<TypeId(0x53d7cc6723a82604a5425ebd39f46af7), (), U32>The constructed value.

render

The types and functions in the render namespace, as returned by import_namespace("render").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
ImageAn image, optimized for usage in rendering. ## Remote Inspection To transmit an [`Image`] between two running Bevy apps, e.g. through BRP, use `SerializedImage`, which requires the `serialize` feature. This type is only meant for short-term transmission between same versions and should not be stored anywhere.
MeshA 3D object made out of vertices representing triangles, lines, or points, with “attribute” values...
StandardMaterialA material with “standard” properties used in PBR lighting. Standard property values with pictures...
NoBackgroundMotionVectorsWhen added to a camera with [`MotionVectorPrepass`], disables the automatic background motion vector prepass. By default, any camera with [`MotionVectorPrepass`]...
TextureAtlasAn index into a [`TextureAtlasLayout`], which corresponds to a specific section of a texture. It stores a handle to [`TextureAtlasLayout`]...
AlphaModeSets how a material’s base color alpha channel is used for transparency.
OpaqueRendererMethodRender method used for opaque materials. The forward rendering main pass draws each mesh entity a...
IndicesAn array of indices into the [`VertexAttributeValues`](super::VertexAttributeValues) for a mesh. It describes the order in which the vertex attributes should be joined into faces.
MeshAttributeCompressionFlagsIf the corresponding attribute compression is enabled: - Position will be Snorm16x4 relative to th...
UvChannelAn enum to define which UV attribute to use for a texture. It only supports two UV attributes, [`Mesh::ATTRIBUTE_UV_0`]...
MorphAttributesAttributes **differences** used for morph targets.
JointAabbNo Documentation 🚧
JointIndexNo Documentation 🚧
SkinnedMeshBoundsData that can be used to calculate the AABB of a skinned mesh.
ParallaxMappingMethodThe [parallax mapping] method to use to compute depth based on the material’s [`depth_map`]. Parallax Mapping uses a depth map texture to give the illusion of depth variation on a mesh surface that is geometrically flat. See the `parallax_...
ReadbackOnceMarker component that pairs with a [`Readback`] to indicate the entity should be despawned after the first [`ReadbackComplete`]...
ShaderBufferA storage buffer that is prepared as a [`RenderAsset`] and uploaded to the GPU. This buffer primarily exists in order to be embedded into a material that implements the [`bevy_render_macros::AsBindGroup`]...
ScreenshotA component that signals to the renderer to capture a screenshot this frame. This component shoul...
ScreenshotCapturedNo Documentation 🚧
MeshExtractableData<Indices>No Documentation 🚧
MeshExtractableData<Unknown>No Documentation 🚧
MeshExtractableData<Unknown>No Documentation 🚧

Image

Opaque Type. 🔒

Description

An image, optimized for usage in rendering.

Remote Inspection

To transmit an [Image] between two running Bevy apps, e.g. through BRP, use SerializedImage, which requires the serialize feature. This type is only meant for short-term transmission between same versions and should not be stored anywhere.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
widthThe width of the image in pixels.
size_f32The size of the image in pixels, as decimal numbers.
heightThe height of the image in pixels.
sizeThe size of the image in pixels.
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

width

The width of the image in pixels.

Arguments

NameTypeDocumentation
_selfImageNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

size_f32

The size of the image in pixels, as decimal numbers.

Arguments

NameTypeDocumentation
_selfImageNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

height

The height of the image in pixels.

Arguments

NameTypeDocumentation
_selfImageNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

size

The size of the image in pixels.

Arguments

NameTypeDocumentation
_selfImageNo Documentation 🚧

Returns

NameTypeDocumentation
returnUVec2No Documentation 🚧

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueImageThe asset value.

Returns

NameTypeDocumentation
handleHandle<Image>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<Image>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<Image>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<Image>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Image>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceImageThe constructed value.

Mesh

Mesh

Description

A 3D object made out of vertices representing triangles, lines, or points, with “attribute” values for each vertex.

Meshes can be automatically generated by a bevy AssetLoader (generally by loading a Gltf file), or by converting a primitive using into. It is also possible to create one manually. They can be edited after creation.

Meshes can be rendered with a Mesh2d and MeshMaterial2d or Mesh3d and MeshMaterial3d for 2D and 3D respectively.

A [Mesh] in Bevy is equivalent to a “primitive” in the glTF format, for a glTF Mesh representation, see GltfMesh.

Manual creation

The following function will construct a flat mesh, to be rendered with a StandardMaterial or ColorMaterial:

# use bevy_mesh::{Mesh, Indices, PrimitiveTopology};
# use bevy_asset::RenderAssetUsages;
fn create_simple_parallelogram() -> Mesh {
    // Create a new mesh using a triangle list topology, where each set of 3 vertices composes a triangle.
    Mesh::new(PrimitiveTopology::TriangleList, RenderAssetUsages::default())
        // Add 4 vertices, each with its own position attribute (coordinate in
        // 3D space), for each of the corners of the parallelogram.
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_POSITION,
            vec![[0.0, 0.0, 0.0], [1.0, 2.0, 0.0], [2.0, 2.0, 0.0], [1.0, 0.0, 0.0]]
        )
        // Assign a UV coordinate to each vertex.
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_UV_0,
            vec![[0.0, 1.0], [0.5, 0.0], [1.0, 0.0], [0.5, 1.0]]
        )
        // Assign normals (everything points outwards)
        .with_inserted_attribute(
            Mesh::ATTRIBUTE_NORMAL,
            vec![[0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]
        )
        // After defining all the vertices and their attributes, build each triangle using the
        // indices of the vertices that make it up in a counter-clockwise order.
        .with_inserted_indices(Indices::U32(vec![
            // First triangle
            0, 3, 1,
            // Second triangle
            1, 3, 2
        ]))
}

You can see how it looks like here, used in a Mesh3d with a square bevy logo texture, with added axis, points, lines and text for clarity.

Other examples

For further visualization, explanation, and examples, see the built-in Bevy examples, and the implementation of the built-in shapes. In particular, generate_custom_mesh teaches you to access and modify the attributes of a [Mesh] after creating it.

Common points of confusion

  • UV maps in Bevy start at the top-left, see ATTRIBUTE_UV_0, other APIs can have other conventions, OpenGL starts at bottom-left.
  • It is possible and sometimes useful for multiple vertices to have the same position attribute value, it’s a common technique in 3D modeling for complex UV mapping or other calculations.
  • Bevy performs frustum culling based on the Aabb of meshes, which is calculated and added automatically for new meshes only. If a mesh is modified, the entity’s Aabb needs to be updated manually or deleted so that it is re-calculated.

Use with StandardMaterial

To render correctly with StandardMaterial, a mesh needs to have properly defined:

  • UVs: Bevy needs to know how to map a texture onto the mesh (also true for ColorMaterial).
  • Normals: Bevy needs to know how light interacts with your mesh. [0.0, 0.0, 1.0] is very common for simple flat meshes on the XY plane, because simple meshes are smooth and they don’t require complex light calculations.
  • Vertex winding order: by default, StandardMaterial.cull_mode is Some(Face::Back), which means that Bevy would only render the “front” of each triangle, which is the side of the triangle from where the vertices appear in a counter-clockwise order.

Remote Inspection

To transmit a [Mesh] between two running Bevy apps, e.g. through BRP, use [SerializedMesh]. This type is only meant for short-term transmission between same versions and should not be stored anywhere.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_shapeA mesh for a shape such as a cuboid or a sphere. Errors if the value is not a shape.
count_verticesThe number of vertices in the mesh.
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

from_shape

A mesh for a shape such as a cuboid or a sphere. Errors if the value is not a shape.

Arguments

NameTypeDocumentation
shapeReflectReferenceNo Documentation 🚧

Returns

NameTypeDocumentation
returnMeshNo Documentation 🚧

count_vertices

The number of vertices in the mesh.

Arguments

NameTypeDocumentation
_selfMeshNo Documentation 🚧

Returns

NameTypeDocumentation
returnUsizeNo Documentation 🚧

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueMeshThe asset value.

Returns

NameTypeDocumentation
handleHandle<Mesh>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<Mesh>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<Mesh>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<Mesh>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Mesh>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshThe constructed value.

StandardMaterial

StandardMaterial

Description

A material with “standard” properties used in PBR lighting. Standard property values with pictures here: https://google.github.io/filament/notes/material_properties.html.

May be created directly from a [Color] or an [Image].

The StandardMaterial can be extended with more data and custom shaders using [ExtendedMaterial]. Examples of how to do this can be found in the Bevy examples.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_colorA material with the given color as its base color and default settings for everything else.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

from_color

A material with the given color as its base color and default settings for everything else.

Arguments

NameTypeDocumentation
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnStandardMaterialNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<StandardMaterial>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceStandardMaterialThe constructed value.

NoBackgroundMotionVectors

NoBackgroundMotionVectors

Description

When added to a camera with [MotionVectorPrepass], disables the automatic background motion vector prepass.

By default, any camera with [MotionVectorPrepass] will automatically write camera-rotation motion vectors for background pixels (those with no geometry, i.e. depth == 0 in reversed-Z). Add this component to opt out, for example if you are writing custom background motion vectors for your own effect.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NoBackgroundMotionVectors>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNoBackgroundMotionVectorsThe constructed value.

TextureAtlas

TextureAtlas

Description

An index into a [TextureAtlasLayout], which corresponds to a specific section of a texture.

It stores a handle to [TextureAtlasLayout] and the index of the current section of the atlas. The texture atlas contains various sections of a given texture, allowing users to have a single image file for either sprite animation or global mapping. You can change the texture index of the atlas to animate the sprite or display only a section of the texture for efficient rendering of related game objects.

Check the following examples for usage:

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TextureAtlas>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTextureAtlasThe constructed value.

AlphaMode

Opaque

Mask

  1. F32

Blend

Premultiplied

AlphaToCoverage

Add

Multiply

Description

Sets how a material’s base color alpha channel is used for transparency.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Add.newNo Documentation 🚧
AlphaToCoverage.newNo Documentation 🚧
Blend.newNo Documentation 🚧
Mask.newNo Documentation 🚧
Multiply.newNo Documentation 🚧
Opaque.newNo Documentation 🚧
Premultiplied.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AlphaMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAlphaModeThe constructed value.

Add.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Add>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

AlphaToCoverage.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::AlphaToCoverage>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

Blend.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Blend>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

Mask.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Mask>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

Multiply.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Multiply>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

Opaque.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Opaque>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

Premultiplied.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode::Premultiplied>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaModeNo Documentation 🚧

OpaqueRendererMethod

Forward

Deferred

Auto

Description

Render method used for opaque materials.

The forward rendering main pass draws each mesh entity and shades it according to its corresponding material and the lights that affect it. Some render features like Screen Space Ambient Occlusion require running depth and normal prepasses, that are ‘deferred’-like prepasses over all mesh entities to populate depth and normal textures. This means that when using render features that require running prepasses, multiple passes over all visible geometry are required. This can be slow if there is a lot of geometry that cannot be batched into few draws.

Deferred rendering runs a prepass to gather not only geometric information like depth and normals, but also all the material properties like base color, emissive color, reflectance, metalness, etc, and writes them into a deferred ‘g-buffer’ texture. The deferred main pass is then a fullscreen pass that reads data from these textures and executes shading. This allows for one pass over geometry, but is at the cost of not being able to use MSAA, and has heavier bandwidth usage which can be unsuitable for low end mobile or other bandwidth-constrained devices.

If a material indicates OpaqueRendererMethod::Auto, DefaultOpaqueRendererMethod will be used.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Deferred.newNo Documentation 🚧
Forward.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<OpaqueRendererMethod>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOpaqueRendererMethodThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OpaqueRendererMethod::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnOpaqueRendererMethodNo Documentation 🚧

Deferred.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OpaqueRendererMethod::Deferred>No Documentation 🚧

Returns

NameTypeDocumentation
returnOpaqueRendererMethodNo Documentation 🚧

Forward.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OpaqueRendererMethod::Forward>No Documentation 🚧

Returns

NameTypeDocumentation
returnOpaqueRendererMethodNo Documentation 🚧

Indices

U16

  1. Vec<U16>

U32

  1. Vec<U32>

Description

An array of indices into the VertexAttributeValues for a mesh.

It describes the order in which the vertex attributes should be joined into faces.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
U16.newNo Documentation 🚧
U32.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Indices>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceIndicesThe constructed value.

U16.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Indices::U16>No Documentation 🚧

Returns

NameTypeDocumentation
returnIndicesNo Documentation 🚧

U32.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Indices::U32>No Documentation 🚧

Returns

NameTypeDocumentation
returnIndicesNo Documentation 🚧

MeshAttributeCompressionFlags

Opaque Type. 🔒

Description

If the corresponding attribute compression is enabled:

  • Position will be Snorm16x4 relative to the mesh’s AABB. The w component is unused.
  • Normal and tangent will be Snorm16x2 with octahedral encoding, using octahedral_encode_signed and octahedral_encode_tangent.
  • UV0 and UV1 will be Unorm16x2. UVs are remapped based on their min/max values so they can go beyond [0, 1], though a larger range will reduce precision.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshAttributeCompressionFlags>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshAttributeCompressionFlagsThe constructed value.

UvChannel

Uv0

Uv1

Description

An enum to define which UV attribute to use for a texture.

It only supports two UV attributes, [Mesh::ATTRIBUTE_UV_0] and [Mesh::ATTRIBUTE_UV_1]. The default is [UvChannel::Uv0].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Uv0.newNo Documentation 🚧
Uv1.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<UvChannel>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceUvChannelThe constructed value.

Uv0.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<UvChannel::Uv0>No Documentation 🚧

Returns

NameTypeDocumentation
returnUvChannelNo Documentation 🚧

Uv1.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<UvChannel::Uv1>No Documentation 🚧

Returns

NameTypeDocumentation
returnUvChannelNo Documentation 🚧

MorphAttributes

MorphAttributes

Description

Attributes differences used for morph targets.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MorphAttributes>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMorphAttributesThe constructed value.

JointAabb

JointAabb

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JointAabb>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJointAabbThe constructed value.

JointIndex

JointIndex

  1. U16

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JointIndex>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJointIndexThe constructed value.

SkinnedMeshBounds

SkinnedMeshBounds

Description

Data that can be used to calculate the AABB of a skinned mesh.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SkinnedMeshBounds>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSkinnedMeshBoundsThe constructed value.

ParallaxMappingMethod

Occlusion

Relief

  • max_steps:U32

Description

The parallax mapping method to use to compute depth based on the material’s depth_map.

Parallax Mapping uses a depth map texture to give the illusion of depth variation on a mesh surface that is geometrically flat.

See the parallax_mapping.wesl shader code for implementation details and explanation of the methods used.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Occlusion.newNo Documentation 🚧
Relief.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ParallaxMappingMethod>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceParallaxMappingMethodThe constructed value.

Occlusion.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ParallaxMappingMethod::Occlusion>No Documentation 🚧

Returns

NameTypeDocumentation
returnParallaxMappingMethodNo Documentation 🚧

Relief.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ParallaxMappingMethod::Relief>No Documentation 🚧

Returns

NameTypeDocumentation
returnParallaxMappingMethodNo Documentation 🚧

ReadbackOnce

ReadbackOnce

Description

Marker component that pairs with a [Readback] to indicate the entity should be despawned after the first [ReadbackComplete] event fires for it.

commands.spawn(ReadbackOnce::buffer(handle));

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReadbackOnce>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReadbackOnceThe constructed value.

ShaderBuffer

Opaque Type. 🔒

Description

A storage buffer that is prepared as a [RenderAsset] and uploaded to the GPU.

This buffer primarily exists in order to be embedded into a material that implements the [bevy_render_macros::AsBindGroup] trait. Compared to embedding a raw [Buffer], [ShaderBuffer] has the advantage that the buffer can be resized without regenerating the materials that embed it.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueShaderBufferThe asset value.

Returns

NameTypeDocumentation
handleHandle<ShaderBuffer>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<ShaderBuffer>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<ShaderBuffer>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<ShaderBuffer>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ShaderBuffer>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceShaderBufferThe constructed value.

Screenshot

Screenshot

  1. RenderTarget

Description

A component that signals to the renderer to capture a screenshot this frame.

This component should be spawned on a new entity with an observer that will trigger with [ScreenshotCaptured] when the screenshot is ready.

Screenshots are captured asynchronously and may not be available immediately after the frame that the component is spawned on. The observer should be used to handle the screenshot when it is ready.

Note that the screenshot entity will be despawned after the screenshot is captured and the observer is triggered.

Usage

# use bevy_ecs::prelude::*;
# use bevy_render::view::screenshot::{save_to_disk, Screenshot};

fn take_screenshot(mut commands: Commands) {
   commands.spawn(Screenshot::primary_window())
      .observe(save_to_disk("screenshot.png"));
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Screenshot>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScreenshotThe constructed value.

ScreenshotCaptured

ScreenshotCaptured

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScreenshotCaptured>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScreenshotCapturedThe constructed value.

MeshExtractableData<Indices>

Data

  1. Indices

NoData

ExtractedToRenderWorld

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Data.newNo Documentation 🚧
ExtractedToRenderWorld.newNo Documentation 🚧
NoData.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshExtractableData<Indices>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshExtractableData<Indices>The constructed value.

Data.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<Indices>::Data>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<Indices>No Documentation 🚧

ExtractedToRenderWorld.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<Indices>::ExtractedToRenderWorld>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<Indices>No Documentation 🚧

NoData.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<Indices>::NoData>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<Indices>No Documentation 🚧

MeshExtractableData<alloc::vec::Vec<alloc::string::String>>

Data

  1. Vec<String>

NoData

ExtractedToRenderWorld

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Data.newNo Documentation 🚧
ExtractedToRenderWorld.newNo Documentation 🚧
NoData.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshExtractableData<alloc::vec::Vecalloc::string::String>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshExtractableData<alloc::vec::Vecalloc::string::String>The constructed value.

Data.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vecalloc::string::String>::Data>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vecalloc::string::String>No Documentation 🚧

ExtractedToRenderWorld.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vecalloc::string::String>::ExtractedToRenderWorld>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vecalloc::string::String>No Documentation 🚧

NoData.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vecalloc::string::String>::NoData>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vecalloc::string::String>No Documentation 🚧

MeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>

Data

  1. Vec<MorphAttributes>

NoData

ExtractedToRenderWorld

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Data.newNo Documentation 🚧
ExtractedToRenderWorld.newNo Documentation 🚧
NoData.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>The constructed value.

Data.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>::Data>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>No Documentation 🚧

ExtractedToRenderWorld.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>::ExtractedToRenderWorld>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>No Documentation 🚧

NoData.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>::NoData>No Documentation 🚧

Returns

NameTypeDocumentation
returnMeshExtractableData<alloc::vec::Vec<bevy_mesh::morph::MorphAttributes>>No Documentation 🚧

smol_str

The types and functions in the smol_str namespace, as returned by import_namespace("smol_str").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
SmolStrNo Documentation 🚧

SmolStr

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SmolStr>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSmolStrThe constructed value.

sprite

The types and functions in the sprite namespace, as returned by import_namespace("sprite").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
TextureAtlasLayoutStores a map used to lookup the position of a texture in a [`TextureAtlas`]. This can be used to either use and look up a specific section of a texture, or animate frame-by-frame as a sprite sheet. Optionally it can store a mapping from sub texture handles to the related area index (see [`TextureAtlasBuilder`]...
AnchorNormalized (relative to its size) offset of a 2d renderable entity from its [`Transform`].
SpriteDescribes a sprite to be rendered to a 2D camera
SpriteAlphaModeAn enum describing how a sprite’s alpha channel will be handled. The base color being modified is ...
SpriteImageModeControls how the image is altered when scaled.
SpriteScalingModeRepresents various modes for proportional scaling of a texture. Can be used in [`SpriteImageMode::Scale`]...
BorderRectDefines border insets that shrink a rectangle from its minimum and maximum corners. This struct i...
SliceScaleModeDefines how a texture slice scales when resized
TextureSlicerSlices a texture using the **9-slicing** technique. This allows to reuse an image at various sizes ...
ColorMaterialA [2d material](Material2d) that renders [2d meshes](crate::Mesh2d) with a texture tinted by a unif...
AlphaMode2dSets how a 2d material’s base color alpha channel is used for transparency. Currently, this only w...
SpriteMeshMaterialNo Documentation 🚧
MeshMaterial2d<ColorMaterial>A [material](Material2d) used for rendering a [`Mesh2d`]. See [`Material2d`] for general information about 2D materials and how to implement your own materials. # Example ``` # use bevy_sprite_render::{ColorMaterial, MeshMaterial2d}; # use bevy_ecs::prelude::*; # use bevy_mesh::{Mesh, Mesh2d}; # use bevy_color::palettes::basic::RED; # use bevy_asset::Assets; # use bevy_shape::Circle; # // Spawn an entity with a mesh using `ColorMaterial`. fn setup( mut commands: Commands, mut meshes: ResMut<Assets>, mut materials: ResMut<Assets>, ) { commands.spawn(( Mesh2d(meshes.add(Circle::new(50.0))), MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))), )); } ``` [`MeshMaterial2d`]...
MeshMaterial2d<SpriteMeshMaterial>A [material](Material2d) used for rendering a [`Mesh2d`]. See [`Material2d`] for general information about 2D materials and how to implement your own materials. # Example ``` # use bevy_sprite_render::{ColorMaterial, MeshMaterial2d}; # use bevy_ecs::prelude::*; # use bevy_mesh::{Mesh, Mesh2d}; # use bevy_color::palettes::basic::RED; # use bevy_asset::Assets; # use bevy_shape::Circle; # // Spawn an entity with a mesh using `ColorMaterial`. fn setup( mut commands: Commands, mut meshes: ResMut<Assets>, mut materials: ResMut<Assets>, ) { commands.spawn(( Mesh2d(meshes.add(Circle::new(50.0))), MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))), )); } ``` [`MeshMaterial2d`]...

TextureAtlasLayout

TextureAtlasLayout

Description

Stores a map used to lookup the position of a texture in a [TextureAtlas]. This can be used to either use and look up a specific section of a texture, or animate frame-by-frame as a sprite sheet.

Optionally it can store a mapping from sub texture handles to the related area index (see TextureAtlasBuilder).

Example usage animating sprite. Example usage animating sprite in response to an event. Example usage loading sprite sheet.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
lenThe number of tiles in the layout.
from_gridA layout of equal tiles in a grid, numbered left to right and then top to bottom. Padding and offset...
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

len

The number of tiles in the layout.

Arguments

NameTypeDocumentation
_selfTextureAtlasLayoutNo Documentation 🚧

Returns

NameTypeDocumentation
returnUsizeNo Documentation 🚧

from_grid

A layout of equal tiles in a grid, numbered left to right and then top to bottom. Padding and offset are in pixels, and default to none.

Arguments

NameTypeDocumentation
tile_sizeUVec2No Documentation 🚧
columnsU32No Documentation 🚧
rowsU32No Documentation 🚧
paddingOptional<UVec2>No Documentation 🚧
offsetOptional<UVec2>No Documentation 🚧

Returns

NameTypeDocumentation
returnTextureAtlasLayoutNo Documentation 🚧

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueTextureAtlasLayoutThe asset value.

Returns

NameTypeDocumentation
handleHandle<TextureAtlasLayout>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<TextureAtlasLayout>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<TextureAtlasLayout>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<TextureAtlasLayout>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TextureAtlasLayout>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTextureAtlasLayoutThe constructed value.

Anchor

Anchor

  1. Vec2

Description

Normalized (relative to its size) offset of a 2d renderable entity from its [Transform].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
top_rightThe anchor in the top right corner.
top_leftThe anchor in the top left corner.
center_rightThe anchor in the middle of the right edge.
bottom_centerThe anchor in the middle of the bottom edge.
as_vecThe offset of the anchor from the center, as a fraction of the sprite size.
bottom_rightThe anchor in the bottom right corner.
center_leftThe anchor in the middle of the left edge.
centerThe anchor in the middle of the sprite.
bottom_leftThe anchor in the bottom left corner.
top_centerThe anchor in the middle of the top edge.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

top_right

The anchor in the top right corner.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

top_left

The anchor in the top left corner.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

center_right

The anchor in the middle of the right edge.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

bottom_center

The anchor in the middle of the bottom edge.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

as_vec

The offset of the anchor from the center, as a fraction of the sprite size.

Arguments

NameTypeDocumentation
_selfAnchorNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

bottom_right

The anchor in the bottom right corner.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

center_left

The anchor in the middle of the left edge.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

center

The anchor in the middle of the sprite.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

bottom_left

The anchor in the bottom left corner.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

top_center

The anchor in the middle of the top edge.

Arguments

Returns

NameTypeDocumentation
returnAnchorNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Anchor>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAnchorThe constructed value.

Sprite

Sprite

Description

Describes a sprite to be rendered to a 2D camera

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
from_colorA solid square of the given color and size.
sizedA sprite with no image that is drawn at the given size.
from_atlas_imageA sprite that shows a section of an image from a texture atlas.
from_imageA sprite that shows the whole image.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

from_color

A solid square of the given color and size.

Arguments

NameTypeDocumentation
colorColorNo Documentation 🚧
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteNo Documentation 🚧

sized

A sprite with no image that is drawn at the given size.

Arguments

NameTypeDocumentation
sizeVec2No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteNo Documentation 🚧

from_atlas_image

A sprite that shows a section of an image from a texture atlas.

Arguments

NameTypeDocumentation
imageHandle<Image>No Documentation 🚧
atlasTextureAtlasNo Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteNo Documentation 🚧

from_image

A sprite that shows the whole image.

Arguments

NameTypeDocumentation
imageHandle<Image>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Sprite>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpriteThe constructed value.

SpriteAlphaMode

Opaque

Mask

  1. F32

Blend

Description

An enum describing how a sprite’s alpha channel will be handled. The base color being modified is that of the texture after tinting. The default is Blend.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Blend.newNo Documentation 🚧
Mask.newNo Documentation 🚧
Opaque.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SpriteAlphaMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpriteAlphaModeThe constructed value.

Blend.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteAlphaMode::Blend>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteAlphaModeNo Documentation 🚧

Mask.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteAlphaMode::Mask>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteAlphaModeNo Documentation 🚧

Opaque.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteAlphaMode::Opaque>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteAlphaModeNo Documentation 🚧

SpriteImageMode

Auto

Scale

  1. SpriteScalingMode

Sliced

  1. TextureSlicer

Tiled

Description

Controls how the image is altered when scaled.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Scale.newNo Documentation 🚧
Sliced.newNo Documentation 🚧
Tiled.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SpriteImageMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpriteImageModeThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteImageMode::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteImageModeNo Documentation 🚧

Scale.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteImageMode::Scale>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteImageModeNo Documentation 🚧

Sliced.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteImageMode::Sliced>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteImageModeNo Documentation 🚧

Tiled.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteImageMode::Tiled>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteImageModeNo Documentation 🚧

SpriteScalingMode

FillCenter

FillStart

FillEnd

FitCenter

FitStart

FitEnd

Description

Represents various modes for proportional scaling of a texture.

Can be used in [SpriteImageMode::Scale].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
FillCenter.newNo Documentation 🚧
FillEnd.newNo Documentation 🚧
FillStart.newNo Documentation 🚧
FitCenter.newNo Documentation 🚧
FitEnd.newNo Documentation 🚧
FitStart.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SpriteScalingMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpriteScalingModeThe constructed value.

FillCenter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FillCenter>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

FillEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FillEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

FillStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FillStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

FitCenter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FitCenter>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

FitEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FitEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

FitStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SpriteScalingMode::FitStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnSpriteScalingModeNo Documentation 🚧

BorderRect

BorderRect

Description

Defines border insets that shrink a rectangle from its minimum and maximum corners.

This struct is used to represent thickness or offsets from the four edges of a rectangle, with values increasing inwards.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BorderRect>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBorderRectThe constructed value.

SliceScaleMode

Stretch

Tile

  • stretch_value:F32

Description

Defines how a texture slice scales when resized

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Stretch.newNo Documentation 🚧
Tile.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SliceScaleMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSliceScaleModeThe constructed value.

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SliceScaleMode::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnSliceScaleModeNo Documentation 🚧

Tile.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<SliceScaleMode::Tile>No Documentation 🚧

Returns

NameTypeDocumentation
returnSliceScaleModeNo Documentation 🚧

TextureSlicer

TextureSlicer

Description

Slices a texture using the 9-slicing technique. This allows to reuse an image at various sizes without needing to prepare multiple assets. The associated texture will be split into nine portions, so that on resize the different portions scale or tile in different ways to keep the texture in proportion.

For example, when resizing a 9-sliced texture the corners will remain unscaled while the other sections will be scaled or tiled.

See 9-sliced textures.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TextureSlicer>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTextureSlicerThe constructed value.

ColorMaterial

ColorMaterial

Description

A 2d material that renders 2d meshes with a texture tinted by a uniform color

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueColorMaterialThe asset value.

Returns

NameTypeDocumentation
handleHandle<ColorMaterial>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<ColorMaterial>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<ColorMaterial>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<ColorMaterial>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ColorMaterial>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceColorMaterialThe constructed value.

AlphaMode2d

Opaque

Mask

  1. F32

Blend

Description

Sets how a 2d material’s base color alpha channel is used for transparency. Currently, this only works with [Mesh2d]. Sprites are always transparent.

This is very similar to [AlphaMode] but this only applies to 2d meshes. We use a separate type because 2d doesn’t support all the transparency modes that 3d does.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Blend.newNo Documentation 🚧
Mask.newNo Documentation 🚧
Opaque.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AlphaMode2d>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAlphaMode2dThe constructed value.

Blend.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode2d::Blend>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaMode2dNo Documentation 🚧

Mask.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode2d::Mask>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaMode2dNo Documentation 🚧

Opaque.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlphaMode2d::Opaque>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlphaMode2dNo Documentation 🚧

SpriteMeshMaterial

SpriteMeshMaterial

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueSpriteMeshMaterialThe asset value.

Returns

NameTypeDocumentation
handleHandle<SpriteMeshMaterial>A handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
handleHandle<SpriteMeshMaterial>The handle to the asset.

Returns

NameTypeDocumentation
assetOptional<SpriteMeshMaterial>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleHandle<SpriteMeshMaterial>A handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<SpriteMeshMaterial>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceSpriteMeshMaterialThe constructed value.

MeshMaterial2d<ColorMaterial>

MeshMaterial2d

  1. Handle<ColorMaterial>

Description

A material used for rendering a [Mesh2d].

See [Material2d] for general information about 2D materials and how to implement your own materials.

Example

# use bevy_sprite_render::{ColorMaterial, MeshMaterial2d};
# use bevy_ecs::prelude::*;
# use bevy_mesh::{Mesh, Mesh2d};
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_shape::Circle;
#
// Spawn an entity with a mesh using `ColorMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands.spawn((
        Mesh2d(meshes.add(Circle::new(50.0))),
        MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshMaterial2d<ColorMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshMaterial2d<ColorMaterial>The constructed value.

MeshMaterial2d<SpriteMeshMaterial>

MeshMaterial2d

  1. Handle<SpriteMeshMaterial>

Description

A material used for rendering a [Mesh2d].

See [Material2d] for general information about 2D materials and how to implement your own materials.

Example

# use bevy_sprite_render::{ColorMaterial, MeshMaterial2d};
# use bevy_ecs::prelude::*;
# use bevy_mesh::{Mesh, Mesh2d};
# use bevy_color::palettes::basic::RED;
# use bevy_asset::Assets;
# use bevy_shape::Circle;
#
// Spawn an entity with a mesh using `ColorMaterial`.
fn setup(
    mut commands: Commands,
    mut meshes: ResMut<Assets<Mesh>>,
    mut materials: ResMut<Assets<ColorMaterial>>,
) {
    commands.spawn((
        Mesh2d(meshes.add(Circle::new(50.0))),
        MeshMaterial2d(materials.add(ColorMaterial::from_color(RED))),
    ));
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MeshMaterial2d<SpriteMeshMaterial>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMeshMaterial2d<SpriteMeshMaterial>The constructed value.

text

The types and functions in the text namespace, as returned by import_namespace("text").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
Text2dThe top-level 2D text component. Adding `Text2d` to an entity will pull in required components fo...
TextFont`TextFont` determines the style of a text span within a [`ComputedTextBlock`], specifically the font face, the font size, the line height, and the antialiasing method.
TextLayoutComponent with text format settings for a block of text. A block of text is composed of text span...
TextSpanA span of text in a tree of spans. A `TextSpan` is only valid when it exists as a child of a pare...
TextThe top-level UI text component. Adding [`Text`] to an entity will pull in required components for setting up a UI text node. The string in this component is the first ‘text span’ in a hierarchy of text spans that are collected into a [`ComputedTextBlock`]...
EmSizeThe font size, in logical pixels, used to resolve `Val::Em` values in a UI node. `Em` units are r...
FontFeatureTagAn OpenType font feature tag.
FontFeaturesOpenType features for .otf fonts that support them. Examples features include ligatures, small-ca...
FontSizeThe vertical height of rasterized glyphs in the font atlas in pixels. This is multiplied by the s...
FontSmoothingDetermines which antialiasing method to use when rendering text. By default, text is rendered with...
FontSourceDetermines how the font face for a text sections is selected. A [`FontSource`] can be a handle to a font asset, a font family name, a CSS font-family list, an ordered family list, or a generic font category that is resolved using Parley’s font database. Font family fallback (selection of a font when the requested font is not found) is automatically handled by [`parley::fontique`]...
FontStyleThe slant style of a font face: normal, italic, or oblique.
FontVariationTagAn OpenType font variation tag.
FontVariationsOpenType font variations for variable fonts that support them. Variable fonts expose named axes (...
FontWeightHow thick or bold the strokes of a font appear. Valid font weights range from 1 to 1000, inclusiv...
FontWidthThe visual width of a font as a ratio of its normal width, typically 0.5 to 2.0. `https://docs\.microsoft\.com/en\-us/typography/opentype/spec/os2\#uswidthclass`...
GenericFontFamilyGeneric font families that are resolved through Parley’s font database.
JustifyDescribes the horizontal alignment of multiple lines of text relative to each other. This only af...
LineBreakDetermines how lines will be broken when preventing text from running out of bounds.
RemSizeThe root font size, in logical pixels. `Rem` units always resolve against this one global resourc...

Values

NameType
EditableTextSystemsReflectSystemSet
Text2dUpdateSystemsReflectSystemSet

Text2d

Text2d

  1. String

Description

The top-level 2D text component.

Adding Text2d to an entity will pull in required components for setting up 2d text. Example usage.

The string in this component is the first ‘text span’ in a hierarchy of text spans that are collected into a [ComputedTextBlock]. See TextSpan for the component used by children of entities with [Text2d].

With Text2d the justify field of [TextLayout] only affects the internal alignment of a block of text and not its relative position, which is controlled by the [Anchor] component. This means that for a block of text consisting of only one line that doesn’t wrap, the justify field will have no effect.

# use bevy_asset::Handle;
# use bevy_color::Color;
# use bevy_color::palettes::basic::BLUE;
# use bevy_ecs::world::World;
# use bevy_text::{Font, FontSize, Justify, TextLayout, TextFont, TextColor, TextSpan};
# use bevy_sprite::Text2d;
#
# let font_handle: Handle<Font> = Default::default();
# let mut world = World::default();
#
// Basic usage.
world.spawn(Text2d::new("hello world!"));

// With non-default style.
world.spawn((
    Text2d::new("hello world!"),
    TextFont {
        font: font_handle.clone().into(),
        font_size: FontSize::Px(60.0),
        ..Default::default()
    },
    TextColor(BLUE.into()),
));

// With text justification.
world.spawn((
    Text2d::new("hello world\nand bevy!"),
    TextLayout::justify(Justify::Center)
));

// With spans
world.spawn(Text2d::new("hello ")).with_children(|parent| {
    parent.spawn(TextSpan::new("world"));
    parent.spawn((TextSpan::new("!"), TextColor(BLUE.into())));
});

Viewport-based FontSize variants for Text2d are resolved based on the primary window’s logical size.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new 2d text component holding `text`.
as_strThe text as a string.
setReplaces the text.

new

Creates a new 2d text component holding text.

Arguments

NameTypeDocumentation
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnText2dNo Documentation 🚧

as_str

The text as a string.

Arguments

NameTypeDocumentation
_selfText2dNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

set

Replaces the text.

Arguments

NameTypeDocumentation
_selfText2dNo Documentation 🚧
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

TextFont

TextFont

Description

TextFont determines the style of a text span within a [ComputedTextBlock], specifically the font face, the font size, the line height, and the antialiasing method.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
with_font_sizeA copy of the text font with its size set to `font_size` in logical pixels.
with_fontA copy of the text font that uses the font face `font`.
from_font_sizeCreates a text font with the default font face and the given size in logical pixels. ```multi-lang-example,lua local TextFont = import_namespace(“text”).TextFont local font = TextFont.from_font_size(20.0) assert(font:with_font_size(30.0) ~= nil) ``` ```multi-lang-example,rune let TextFont = import_...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

with_font_size

A copy of the text font with its size set to font_size in logical pixels.

Arguments

NameTypeDocumentation
_selfTextFontNo Documentation 🚧
font_sizeF32No Documentation 🚧

Returns

NameTypeDocumentation
returnTextFontNo Documentation 🚧

with_font

A copy of the text font that uses the font face font.

Arguments

NameTypeDocumentation
_selfTextFontNo Documentation 🚧
fontbevy_asset::handle::Handle<bevy_text::font::Font>No Documentation 🚧

Returns

NameTypeDocumentation
returnTextFontNo Documentation 🚧

from_font_size

Creates a text font with the default font face and the given size in logical pixels.

local TextFont = import_namespace("text").TextFont
local font = TextFont.from_font_size(20.0)
assert(font:with_font_size(30.0) ~= nil)
let TextFont = import_namespace("text").TextFont;
let font = TextFont.from_font_size(20.0);
assert!(font.with_font_size(30.0) != ());

Arguments

NameTypeDocumentation
font_sizeF32No Documentation 🚧

Returns

NameTypeDocumentation
returnTextFontNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TextFont>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTextFontThe constructed value.

TextLayout

TextLayout

Description

Component with text format settings for a block of text.

A block of text is composed of text spans, which each have a separate string value and [TextFont]. Text spans associated with a text block are collected into [ComputedTextBlock] for layout, and then inserted to [TextLayoutInfo] for rendering.

See Text2d in bevy_sprite for the core component of 2d text, and Text in bevy_ui for UI text.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
new_with_no_wrapA text layout that never wraps soft line breaks, only explicit newlines start a new line.
new_with_justifyA text layout that aligns lines with the given justification and wraps at word boundaries.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new_with_no_wrap

A text layout that never wraps soft line breaks, only explicit newlines start a new line.

Arguments

Returns

NameTypeDocumentation
returnTextLayoutNo Documentation 🚧

new_with_justify

A text layout that aligns lines with the given justification and wraps at word boundaries.

Arguments

NameTypeDocumentation
justifyJustifyNo Documentation 🚧

Returns

NameTypeDocumentation
returnTextLayoutNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TextLayout>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTextLayoutThe constructed value.

TextSpan

TextSpan

  1. String

Description

A span of text in a tree of spans.

A TextSpan is only valid when it exists as a child of a parent that has either Text or Text2d. The parent’s Text / Text2d component contains the base text content. Any children with TextSpan extend this text by appending their content to the parent’s text in sequence to form a [ComputedTextBlock]. The parent’s [TextLayout] determines the layout of the block but each node has its own [TextFont] and [TextColor].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newCreates a new text span holding `text`.
setReplaces the text.
as_strThe text as a string.

new

Creates a new text span holding text.

Arguments

NameTypeDocumentation
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnTextSpanNo Documentation 🚧

set

Replaces the text.

Arguments

NameTypeDocumentation
_selfTextSpanNo Documentation 🚧
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

as_str

The text as a string.

Arguments

NameTypeDocumentation
_selfTextSpanNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

Text

Text

  1. String

Description

The top-level UI text component.

Adding [Text] to an entity will pull in required components for setting up a UI text node.

The string in this component is the first ‘text span’ in a hierarchy of text spans that are collected into a [ComputedTextBlock]. See TextSpan for the component used by children of entities with [Text].

# use bevy_asset::Handle;
# use bevy_color::Color;
# use bevy_color::palettes::basic::BLUE;
# use bevy_ecs::world::World;
# use bevy_text::{Font, FontSize, Justify, TextLayout, TextFont, TextColor, TextSpan};
# use bevy_ui::prelude::Text;
#
# let font_handle: Handle<Font> = Default::default();
# let mut world = World::default();
#
// Basic usage.
world.spawn(Text::new("hello world!"));

// With non-default style.
world.spawn((
    Text::new("hello world!"),
    TextFont {
        font: font_handle.clone().into(),
        font_size: FontSize::Px(60.0),
        ..Default::default()
    },
    TextColor(BLUE.into()),
));

// With text justification.
world.spawn((
    Text::new("hello world\nand bevy!"),
    TextLayout::justify(Justify::Center)
));

// With spans
world.spawn(Text::new("hello ")).with_children(|parent| {
    parent.spawn(TextSpan::new("world"));
    parent.spawn((TextSpan::new("!"), TextColor(BLUE.into())));
});

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
setReplaces the text.
as_strThe text as a string.
newCreates a new text component holding `text`. ```multi-lang-example,lua local Text = import_namespace(“text”).Text local text = Text.new(“hi”) assert(text:as_str() == “hi”) `...

set

Replaces the text.

Arguments

NameTypeDocumentation
_selfTextNo Documentation 🚧
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

as_str

The text as a string.

Arguments

NameTypeDocumentation
_selfTextNo Documentation 🚧

Returns

NameTypeDocumentation
returnStringNo Documentation 🚧

new

Creates a new text component holding text.

local Text = import_namespace("text").Text
local text = Text.new("hi")
assert(text:as_str() == "hi")
let Text = import_namespace("text").Text;
let text = Text.new("hi");
assert!(text.as_str() == "hi");

Arguments

NameTypeDocumentation
textStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnTextNo Documentation 🚧

EmSize

EmSize

  1. F32

Description

The font size, in logical pixels, used to resolve Val::Em values in a UI node.

Em units are relative to the font size of the node they sit on, and this is that font size made concrete. Required by Node, so every UI node has one.

If the node has a TextFont, the EmSize is derived from it whenever the TextFont, RemSize or render-target info changes; until then any value you place on it persists. If it does not have a TextFont, the value is yours to set, for example by an app-level propagation system. EmSize defaults to [DEFAULT_REM_SIZE_PX], which matches the default [RemSize] but does not track changes to it. Use Val::Rem instead for values that should follow the root font size.

Removing a TextFont leaves the last derived value in place.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<EmSize>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceEmSizeThe constructed value.

FontFeatureTag

FontFeatureTag

  1. [U8; 4]

Description

An OpenType font feature tag.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontFeatureTag>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontFeatureTagThe constructed value.

FontFeatures

FontFeatures

Description

OpenType features for .otf fonts that support them.

Examples features include ligatures, small-caps, and fractional number display. For the complete list of OpenType features, see the spec at <https://learn.microsoft.com/en-us/typography/opentype/spec/featurelist>.

Usage:

use bevy_text::{FontFeatureTag, FontFeatures};

// Create using the builder
let font_features = FontFeatures::builder()
  .enable(FontFeatureTag::STANDARD_LIGATURES)
  .set(FontFeatureTag::WEIGHT, 300)
  .build();

// Create from a list
let more_font_features: FontFeatures = [
  FontFeatureTag::STANDARD_LIGATURES,
  FontFeatureTag::OLDSTYLE_FIGURES,
  FontFeatureTag::TABULAR_FIGURES
].into();

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontFeatures>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontFeaturesThe constructed value.

FontSize

Px

  1. F32

Vw

  1. F32

Vh

  1. F32

VMin

  1. F32

VMax

  1. F32

Rem

  1. F32

Description

The vertical height of rasterized glyphs in the font atlas in pixels.

This is multiplied by the scale factor, but not the text entity transform or camera projection.

The viewport variants are not supported by Text2d.

A new font atlas is generated for every combination of font handle and scaled font size which can have a strong performance impact.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Px.newNo Documentation 🚧
Rem.newNo Documentation 🚧
VMax.newNo Documentation 🚧
VMin.newNo Documentation 🚧
Vh.newNo Documentation 🚧
Vw.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontSize>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontSizeThe constructed value.

Px.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::Px>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

Rem.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::Rem>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

VMax.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::VMax>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

VMin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::VMin>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

Vh.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::Vh>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

Vw.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSize::Vw>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSizeNo Documentation 🚧

FontSmoothing

None

AntiAliased

Description

Determines which antialiasing method to use when rendering text. By default, text is rendered with grayscale antialiasing, but this can be changed to achieve a pixelated look.

Note: Subpixel antialiasing is not currently supported.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AntiAliased.newNo Documentation 🚧
None.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontSmoothing>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontSmoothingThe constructed value.

AntiAliased.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSmoothing::AntiAliased>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSmoothingNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSmoothing::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSmoothingNo Documentation 🚧

FontSource

Handle

  1. bevy_asset::handle::Handle<bevy_text::font::Font>

Family

  1. SmolStr

Families

  1. SmolStr

List

  1. Vec<FontSource>

Generic

  1. GenericFontFamily

Description

Determines how the font face for a text sections is selected.

A [FontSource] can be a handle to a font asset, a font family name, a CSS font-family list, an ordered family list, or a generic font category that is resolved using Parley’s font database.

Font family fallback (selection of a font when the requested font is not found) is automatically handled by [parley::fontique]. Be sure to enable the parley/system feature for automatic discovery of system fonts.

Generally speaking, these fallbacks are OS-specific, and do not require manual configuration.

You can check which font family is used for a given [FontSource] by calling FontCx::get_family.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Families.newNo Documentation 🚧
Family.newNo Documentation 🚧
Generic.newNo Documentation 🚧
Handle.newNo Documentation 🚧
List.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontSource>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontSourceThe constructed value.

Families.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSource::Families>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSourceNo Documentation 🚧

Family.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSource::Family>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSourceNo Documentation 🚧

Generic.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSource::Generic>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSourceNo Documentation 🚧

Handle.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSource::Handle>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSourceNo Documentation 🚧

List.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontSource::List>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontSourceNo Documentation 🚧

FontStyle

Normal

Italic

Oblique

  1. Optional<F32>

Description

The slant style of a font face: normal, italic, or oblique.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Italic.newNo Documentation 🚧
Normal.newNo Documentation 🚧
Oblique.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontStyle>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontStyleThe constructed value.

Italic.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontStyle::Italic>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontStyleNo Documentation 🚧

Normal.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontStyle::Normal>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontStyleNo Documentation 🚧

Oblique.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FontStyle::Oblique>No Documentation 🚧

Returns

NameTypeDocumentation
returnFontStyleNo Documentation 🚧

FontVariationTag

FontVariationTag

  1. [U8; 4]

Description

An OpenType font variation tag.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontVariationTag>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontVariationTagThe constructed value.

FontVariations

FontVariations

Description

OpenType font variations for variable fonts that support them.

Variable fonts expose named axes (e.g. wght, FILL) that accept continuous f32 values. This is distinct from [FontFeatures], which mainly controls on/off OpenType layout features.

Usage

use bevy_text::{FontVariationTag, FontVariations};

let variations = FontVariations::builder()
    .set(FontVariationTag::WEIGHT, 400.0)
    .build();

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontVariations>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontVariationsThe constructed value.

FontWeight

FontWeight

  1. U16

Description

How thick or bold the strokes of a font appear.

Valid font weights range from 1 to 1000, inclusive. Weights above 1000 are clamped to 1000. A weight of 0 is treated as [FontWeight::DEFAULT].

Legacy names from when most fonts weren’t variable fonts are included as const values, but are misleading if used in documentation and examples, as valid weights for variable fonts are all of the numbers from 1-1000, and not all fonts which are not variable fonts have those weights supplied. If you use a custom font that supplies only specific weights, that will be documented where you purchased the font.

<https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/font-weight>

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontWeight>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontWeightThe constructed value.

FontWidth

FontWidth

  1. F32

Description

The visual width of a font as a ratio of its normal width, typically 0.5 to 2.0. <https://docs.microsoft.com/en-us/typography/opentype/spec/os2#uswidthclass>

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FontWidth>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFontWidthThe constructed value.

GenericFontFamily

Serif

SansSerif

Cursive

Fantasy

Monospace

SystemUi

UiSerif

UiSansSerif

UiMonospace

UiRounded

Emoji

Math

FangSong

Description

Generic font families that are resolved through Parley’s font database.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Cursive.newNo Documentation 🚧
Emoji.newNo Documentation 🚧
FangSong.newNo Documentation 🚧
Fantasy.newNo Documentation 🚧
Math.newNo Documentation 🚧
Monospace.newNo Documentation 🚧
SansSerif.newNo Documentation 🚧
Serif.newNo Documentation 🚧
SystemUi.newNo Documentation 🚧
UiMonospace.newNo Documentation 🚧
UiRounded.newNo Documentation 🚧
UiSansSerif.newNo Documentation 🚧
UiSerif.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GenericFontFamily>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGenericFontFamilyThe constructed value.

Cursive.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Cursive>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Emoji.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Emoji>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

FangSong.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::FangSong>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Fantasy.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Fantasy>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Math.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Math>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Monospace.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Monospace>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

SansSerif.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::SansSerif>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Serif.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::Serif>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

SystemUi.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::SystemUi>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

UiMonospace.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::UiMonospace>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

UiRounded.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::UiRounded>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

UiSansSerif.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::UiSansSerif>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

UiSerif.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GenericFontFamily::UiSerif>No Documentation 🚧

Returns

NameTypeDocumentation
returnGenericFontFamilyNo Documentation 🚧

Justify

Left

Center

Right

Justified

Start

End

Description

Describes the horizontal alignment of multiple lines of text relative to each other.

This only affects the internal positioning of the lines of text within a text entity and does not affect the text entity’s position.

Has no affect on a single line text entity, unless used together with a TextBounds component with an explicit width value.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Center.newNo Documentation 🚧
End.newNo Documentation 🚧
Justified.newNo Documentation 🚧
Left.newNo Documentation 🚧
Right.newNo Documentation 🚧
Start.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Justify>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJustifyThe constructed value.

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

Justified.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::Justified>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

Left.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::Left>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

Right.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::Right>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Justify::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyNo Documentation 🚧

LineBreak

WordBoundary

AnyCharacter

WordOrCharacter

NoWrap

Description

Determines how lines will be broken when preventing text from running out of bounds.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AnyCharacter.newNo Documentation 🚧
NoWrap.newNo Documentation 🚧
WordBoundary.newNo Documentation 🚧
WordOrCharacter.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<LineBreak>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceLineBreakThe constructed value.

AnyCharacter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<LineBreak::AnyCharacter>No Documentation 🚧

Returns

NameTypeDocumentation
returnLineBreakNo Documentation 🚧

NoWrap.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<LineBreak::NoWrap>No Documentation 🚧

Returns

NameTypeDocumentation
returnLineBreakNo Documentation 🚧

WordBoundary.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<LineBreak::WordBoundary>No Documentation 🚧

Returns

NameTypeDocumentation
returnLineBreakNo Documentation 🚧

WordOrCharacter.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<LineBreak::WordOrCharacter>No Documentation 🚧

Returns

NameTypeDocumentation
returnLineBreakNo Documentation 🚧

RemSize

RemSize

  1. F32

Description

The root font size, in logical pixels.

Rem units always resolve against this one global resource, including FontSize::Rem, LetterSpacing::Rem and Val::Rem.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RemSize>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRemSizeThe constructed value.

time

The types and functions in the time namespace, as returned by import_namespace("time").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
InstantNo Documentation 🚧
StopwatchA Stopwatch is a struct that tracks elapsed time when started. Note that in order to advance the ...
TimerTracks elapsed time. Enters the finished state once `duration` is reached. Note that in order to ...
DurationNo Documentation 🚧
Time<Unknown>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Fixed>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Real>A generic clock resource that tracks how much it has advanced since its previous update and since ...
Time<Virtual>A generic clock resource that tracks how much it has advanced since its previous update and since ...
FixedThe fixed timestep game clock following virtual time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`]...
RealReal time clock representing elapsed wall clock time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`]...
TimerModeSpecifies [`Timer`] behavior.
VirtualThe virtual game clock representing game time. A specialization of the [`Time`] structure. **For method documentation, see [`Time#impl-Time`].**...

Values

NameType
TimeSystemsReflectSystemSet

Instant

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
duration_sinceThe duration from `earlier` to this instant, or zero if `earlier` is later.
elapsedThe duration since this instant was taken.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

duration_since

The duration from earlier to this instant, or zero if earlier is later.

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧
earlierInstantNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

elapsed

The duration since this instant was taken.

Arguments

NameTypeDocumentation
_selfInstantNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Instant>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInstantThe constructed value.

Stopwatch

Stopwatch

Description

A Stopwatch is a struct that tracks elapsed time when started.

Note that in order to advance the stopwatch tick MUST be called.

Examples

# use bevy_time::*;
use std::time::Duration;
let mut stopwatch = Stopwatch::new();
assert_eq!(stopwatch.elapsed_secs(), 0.0);

stopwatch.tick(Duration::from_secs_f32(1.0)); // tick one second
assert_eq!(stopwatch.elapsed_secs(), 1.0);

stopwatch.pause();
stopwatch.tick(Duration::from_secs_f32(1.0)); // paused stopwatches don't tick
assert_eq!(stopwatch.elapsed_secs(), 1.0);

stopwatch.reset(); // reset the stopwatch
assert!(stopwatch.is_paused());
assert_eq!(stopwatch.elapsed_secs(), 0.0);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
set_elapsedSets the time the stopwatch has run for.
unpauseResumes a paused stopwatch.
elapsedThe time the stopwatch has run for.
tickAdvances the stopwatch by `delta`, given in seconds or as a duration. Errors if the time is negative...
newA stopwatch at zero, which is running.
is_pausedWhether the stopwatch is paused.
resetSets the stopwatch back to zero elapsed time.
pauseStops the stopwatch from advancing until it is unpaused.
elapsed_secsThe time the stopwatch has run for, in seconds.

set_elapsed

Sets the time the stopwatch has run for.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧
elapsedDurationNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

unpause

Resumes a paused stopwatch.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

elapsed

The time the stopwatch has run for.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

tick

Advances the stopwatch by delta, given in seconds or as a duration. Errors if the time is negative.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧
deltaF32Duration

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

A stopwatch at zero, which is running.

Arguments

Returns

NameTypeDocumentation
returnStopwatchNo Documentation 🚧

is_paused

Whether the stopwatch is paused.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

reset

Sets the stopwatch back to zero elapsed time.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

pause

Stops the stopwatch from advancing until it is unpaused.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

elapsed_secs

The time the stopwatch has run for, in seconds.

Arguments

NameTypeDocumentation
_selfStopwatchNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

Timer

Timer

Description

Tracks elapsed time. Enters the finished state once duration is reached.

Note that in order to advance the timer tick MUST be called.

Timer modes

There are two timer modes ([TimerMode]):

  • Non repeating timers will stop tracking and stay in the finished state until reset.
  • Repeating timers will only be in the finished state on each tick duration is reached or exceeded, and can still be reset at any given point.

Pausing timers

You can pause a timer using [Timer::pause]. Paused timers will not have elapsed time increased.

Elapsing multiple times a frame

Repeating timers might elapse multiple times per frame if the time is advanced by more than the timer duration. You can check how many times a timer elapsed each tick with [Timer::times_finished_this_tick]. For non-repeating timers, this will always be 0 or 1.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
fraction_remainingHow much of the duration is left, from `0` to `1`.
set_modeSets whether the timer runs once, or repeats.
remainingThe time left until the timer finishes.
just_finishedWhether the timer finished during the last tick.
elapsedThe time the timer has run for.
set_elapsedSets the time the timer has run for.
pauseStops the timer from advancing until it is unpaused.
durationThe duration the timer runs for.
elapsed_secsThe time the timer has run for, in seconds.
pausedWhether the timer is paused.
times_finished_this_tickHow many times the timer finished during the last tick, which can be more than once for a short time...
set_durationSets the duration the timer runs for.
remaining_secsThe time left until the timer finishes, in seconds.
resetSets the timer back to zero elapsed time, keeping its duration and mode.
fractionHow much of the duration has passed, from `0` to `1`.
tickAdvances the timer by `delta`, given in seconds or as a duration. Errors if the time is negative.
finishedWhether the timer has run for its full duration.
almost_finishMakes the timer finish on its next tick.
newA timer which runs for `duration`, in `mode`.
modeWhether the timer runs once, or repeats.
from_secondsA timer which runs for `secs` seconds, in `mode`. Errors if `secs` is negative or not finite. ```multi-lang-example,lua local Timer = import_namespace(“time”).Timer local TimerMode = import_namespace(“time”).TimerMode local timer = Timer.from_seconds(2, TimerMode.Repeating) timer:tick(1) assert(not timer:finished()) timer:tick(1.5) assert(timer:finished()) ``` ```multi-lang-example,rune let Timer = import_...
unpauseResumes a paused timer.

fraction_remaining

How much of the duration is left, from 0 to 1.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

set_mode

Sets whether the timer runs once, or repeats.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

remaining

The time left until the timer finishes.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

just_finished

Whether the timer finished during the last tick.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

elapsed

The time the timer has run for.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

set_elapsed

Sets the time the timer has run for.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
elapsedDurationNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

pause

Stops the timer from advancing until it is unpaused.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

duration

The duration the timer runs for.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

elapsed_secs

The time the timer has run for, in seconds.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

paused

Whether the timer is paused.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

times_finished_this_tick

How many times the timer finished during the last tick, which can be more than once for a short timer.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

set_duration

Sets the duration the timer runs for.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
durationDurationNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

remaining_secs

The time left until the timer finishes, in seconds.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

reset

Sets the timer back to zero elapsed time, keeping its duration and mode.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

fraction

How much of the duration has passed, from 0 to 1.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

tick

Advances the timer by delta, given in seconds or as a duration. Errors if the time is negative.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧
deltaF32Duration

Returns

NameTypeDocumentation
return()No Documentation 🚧

finished

Whether the timer has run for its full duration.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

almost_finish

Makes the timer finish on its next tick.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

A timer which runs for duration, in mode.

Arguments

NameTypeDocumentation
durationDurationNo Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
returnTimerNo Documentation 🚧

mode

Whether the timer runs once, or repeats.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
returnTimerModeNo Documentation 🚧

from_seconds

A timer which runs for secs seconds, in mode. Errors if secs is negative or not finite.

local Timer = import_namespace("time").Timer
local TimerMode = import_namespace("time").TimerMode
local timer = Timer.from_seconds(2, TimerMode.Repeating)
timer:tick(1)
assert(not timer:finished())
timer:tick(1.5)
assert(timer:finished())
let Timer = import_namespace("time").Timer;
let TimerMode = import_namespace("time").TimerMode;
let timer = Timer.from_seconds(2.0, TimerMode.Repeating);
timer.tick(1.0);
assert!(!timer.finished());
timer.tick(1.5);
assert!(timer.finished());

Arguments

NameTypeDocumentation
secsF32No Documentation 🚧
modeTimerModeNo Documentation 🚧

Returns

NameTypeDocumentation
returnTimerNo Documentation 🚧

unpause

Resumes a paused timer.

Arguments

NameTypeDocumentation
_selfTimerNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

Duration

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
as_secs_f64The duration in seconds, as a double precision number.
addThe sum of two durations, capped at the largest representable duration.
mulThe duration scaled by `factor`. Errors if `factor` is negative or not finite.
subThe difference of two durations, or zero if `rhs` is the longer one.
ltWhether this duration is shorter than `other`.
as_secsThe duration in seconds.
from_nanosA duration of `nanos` nanoseconds.
zeroA duration of no time.
from_millisA duration of `millis` milliseconds.
is_zeroWhether the duration is zero.
as_millisThe duration in whole milliseconds, rounded down.
divThe duration divided by `divisor`. Errors if `divisor` is not positive.
from_microsA duration of `micros` microseconds.
eqWhether two durations are equal.
from_secsA duration of `secs` seconds. Errors if `secs` is negative or not finite.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

as_secs_f64

The duration in seconds, as a double precision number.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

add

The sum of two durations, capped at the largest representable duration.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

mul

The duration scaled by factor. Errors if factor is negative or not finite.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
factorF32No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

sub

The difference of two durations, or zero if rhs is the longer one.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
rhsDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

lt

Whether this duration is shorter than other.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

as_secs

The duration in seconds.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

from_nanos

A duration of nanos nanoseconds.

Arguments

NameTypeDocumentation
nanosU64No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

zero

A duration of no time.

Arguments

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

from_millis

A duration of millis milliseconds.

Arguments

NameTypeDocumentation
millisU64No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

is_zero

Whether the duration is zero.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

as_millis

The duration in whole milliseconds, rounded down.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnU64No Documentation 🚧

div

The duration divided by divisor. Errors if divisor is not positive.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
divisorF32No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

from_micros

A duration of micros microseconds.

Arguments

NameTypeDocumentation
microsU64No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

eq

Whether two durations are equal.

Arguments

NameTypeDocumentation
_selfDurationNo Documentation 🚧
otherDurationNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

from_secs

A duration of secs seconds. Errors if secs is negative or not finite.

Arguments

NameTypeDocumentation
secsF32No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Duration>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDurationThe constructed value.

Time<()>

Time

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to “current” or “default” time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Message)]
struct Pause(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut pause_reader: MessageReader<Pause>) {
    for pause in pause_reader.read() {
        if pause.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it’s probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the “generic” Time clock resource if the “default” time for your game should not be the default virtual time provided. You can get a “generic” snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_platform::time::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
elapsed_secs_wrappedThe total time that passed since the clock started, in seconds, wrapped to a period so it stays prec...
deltaThe time that passed since the previous update.
delta_secs_f64The time that passed since the previous update, in seconds as a double precision number.
elapsed_secs_f64The total time that passed since the clock started, in seconds as a double precision number.
delta_secsThe time that passed since the previous update, in seconds.
elapsed_secsThe total time that passed since the clock started, in seconds.
elapsedThe total time that passed since the clock started.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

elapsed_secs_wrapped

The total time that passed since the clock started, in seconds, wrapped to a period so it stays precise for long running apps.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

delta

The time that passed since the previous update.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

delta_secs_f64

The time that passed since the previous update, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

elapsed_secs_f64

The total time that passed since the clock started, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

delta_secs

The time that passed since the previous update, in seconds.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed_secs

The total time that passed since the clock started, in seconds.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed

The total time that passed since the clock started.

Arguments

NameTypeDocumentation
_selfTime<()>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Time<()>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTime<()>The constructed value.

Time<Fixed>

Time

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to “current” or “default” time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Message)]
struct Pause(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut pause_reader: MessageReader<Pause>) {
    for pause in pause_reader.read() {
        if pause.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it’s probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the “generic” Time clock resource if the “default” time for your game should not be the default virtual time provided. You can get a “generic” snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_platform::time::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
delta_secsThe time that passed since the previous update, in seconds.
delta_secs_f64The time that passed since the previous update, in seconds as a double precision number.
elapsed_secsThe total time that passed since the clock started, in seconds.
elapsed_secs_wrappedThe total time that passed since the clock started, in seconds, wrapped to a period so it stays prec...
elapsed_secs_f64The total time that passed since the clock started, in seconds as a double precision number.
elapsedThe total time that passed since the clock started.
timestepThe length of one fixed update step.
set_timestep_secondsSets the length of one fixed update step, in seconds. Errors if `seconds` is not positive or not fin...
overstep_fractionHow far the clock is into the next fixed update step, from `0` to `1`.
deltaThe time that passed since the previous update.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

delta_secs

The time that passed since the previous update, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

delta_secs_f64

The time that passed since the previous update, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

elapsed_secs

The total time that passed since the clock started, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed_secs_wrapped

The total time that passed since the clock started, in seconds, wrapped to a period so it stays precise for long running apps.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed_secs_f64

The total time that passed since the clock started, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

elapsed

The total time that passed since the clock started.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

timestep

The length of one fixed update step.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

set_timestep_seconds

Sets the length of one fixed update step, in seconds. Errors if seconds is not positive or not finite.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧
secondsF64No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

overstep_fraction

How far the clock is into the next fixed update step, from 0 to 1.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

delta

The time that passed since the previous update.

Arguments

NameTypeDocumentation
_selfTime<Fixed>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Time<Fixed>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTime<Fixed>The constructed value.

Time<Real>

Time

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to “current” or “default” time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Message)]
struct Pause(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut pause_reader: MessageReader<Pause>) {
    for pause in pause_reader.read() {
        if pause.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it’s probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the “generic” Time clock resource if the “default” time for your game should not be the default virtual time provided. You can get a “generic” snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_platform::time::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
delta_secsThe time that passed since the previous update, in seconds.
elapsed_secs_f64The total time that passed since the clock started, in seconds as a double precision number.
elapsed_secsThe total time that passed since the clock started, in seconds.
elapsed_secs_wrappedThe total time that passed since the clock started, in seconds, wrapped to a period so it stays prec...
delta_secs_f64The time that passed since the previous update, in seconds as a double precision number.
elapsedThe total time that passed since the clock started.
deltaThe time that passed since the previous update.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

delta_secs

The time that passed since the previous update, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed_secs_f64

The total time that passed since the clock started, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

elapsed_secs

The total time that passed since the clock started, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

elapsed_secs_wrapped

The total time that passed since the clock started, in seconds, wrapped to a period so it stays precise for long running apps.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

delta_secs_f64

The time that passed since the previous update, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

elapsed

The total time that passed since the clock started.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

delta

The time that passed since the previous update.

Arguments

NameTypeDocumentation
_selfTime<Real>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Time<Real>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTime<Real>The constructed value.

Time<Virtual>

Time

Description

A generic clock resource that tracks how much it has advanced since its previous update and since its creation.

Multiple instances of this resource are inserted automatically by TimePlugin:

  • Time<Real> tracks real wall-clock time elapsed.
  • Time<Virtual> tracks virtual game time that may be paused or scaled.
  • Time<Fixed> tracks fixed timesteps based on virtual time.
  • [Time] is a generic clock that corresponds to “current” or “default” time for systems. It contains Time<Virtual> except inside the FixedMain schedule when it contains Time<Fixed>.

The time elapsed since the previous time this clock was advanced is saved as delta() and the total amount of time the clock has advanced is saved as elapsed(). Both are represented as exact [Duration] values with fixed nanosecond precision. The clock does not support time moving backwards, but it can be updated with [Duration::ZERO] which will set delta() to zero.

These values are also available in seconds as f32 via delta_secs() and elapsed_secs(), and also in seconds as f64 via delta_secs_f64() and elapsed_secs_f64().

Since elapsed_secs() will grow constantly and is f32, it will exhibit gradual precision loss. For applications that require an f32 value but suffer from gradual precision loss there is elapsed_secs_wrapped() available. The same wrapped value is also available as [Duration] and f64 for consistency. The wrap period is by default 1 hour, and can be set by set_wrap_period().

Accessing clocks

By default, any systems requiring current delta() or elapsed() should use Res<Time> to access the default time configured for the program. By default, this refers to Time<Virtual> except during the FixedMain schedule when it refers to Time<Fixed>. This ensures your system can be used either in Update or FixedUpdate schedule depending on what is needed.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn ambivalent_system(time: Res<Time>) {
    println!("this how I see time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system needs to react based on real time (wall clock time), like for user interfaces, it should use Res<Time<Real>>. The delta() and elapsed() values will always correspond to real time and will not be affected by pause, time scaling or other tweaks.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn real_time_system(time: Res<Time<Real>>) {
    println!("this will always be real time: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

If your system specifically needs to access fixed timestep clock, even when placed in Update schedule, you should use Res<Time<Fixed>>. The delta() and elapsed() values will correspond to the latest fixed timestep that has been run.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Fixed>>) {
    println!("this will always be the last executed fixed timestep: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
}

Finally, if your system specifically needs to know the current virtual game time, even if placed inside FixedUpdate, for example to know if the game is was_paused() or to use effective_speed(), you can use Res<Time<Virtual>>. However, if the system is placed in FixedUpdate, extra care must be used because your system might be run multiple times with the same delta() and elapsed() values as the virtual game time has not changed between the iterations.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
fn fixed_time_system(time: Res<Time<Virtual>>) {
    println!("this will be virtual time for this update: delta {:?}, elapsed {:?}", time.delta(), time.elapsed());
    println!("also the relative speed of the game is now {}", time.effective_speed());
}

If you need to change the settings for any of the clocks, for example to pause() the game, you should use ResMut<Time<Virtual>>.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
#
#[derive(Message)]
struct Pause(bool);

fn pause_system(mut time: ResMut<Time<Virtual>>, mut pause_reader: MessageReader<Pause>) {
    for pause in pause_reader.read() {
        if pause.0 {
            time.pause();
        } else {
            time.unpause();
        }
    }
}

Adding custom clocks

New custom clocks can be created by creating your own struct as a context and passing it to new_with(). These clocks can be inserted as resources as normal and then accessed by systems. You can use the advance_by() or advance_to() methods to move the clock forwards based on your own logic.

If you want to add methods for your time instance and they require access to both your context and the generic time part, it’s probably simplest to add a custom trait for them and implement it for Time<Custom>.

Your context struct will need to implement the [Default] trait because [Time] structures support reflection. It also makes initialization trivial by being able to call app.init_resource::<Time<Custom>>().

You can also replace the “generic” Time clock resource if the “default” time for your game should not be the default virtual time provided. You can get a “generic” snapshot of your clock by calling as_generic() and then overwrite the [Time] resource with it. The default systems added by TimePlugin will overwrite the [Time] clock during First and FixedUpdate schedules.

# use bevy_ecs::prelude::*;
# use bevy_time::prelude::*;
# use bevy_platform::time::Instant;
#
#[derive(Debug)]
struct Custom {
    last_external_time: Instant,
}

impl Default for Custom {
    fn default() -> Self {
        Self {
            last_external_time: Instant::now(),
        }
    }
}

trait CustomTime {
    fn update_from_external(&mut self, instant: Instant);
}

impl CustomTime for Time<Custom> {
    fn update_from_external(&mut self, instant: Instant) {
         let delta = instant - self.context().last_external_time;
         self.advance_by(delta);
         self.context_mut().last_external_time = instant;
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
delta_secsThe time that passed since the previous update, in seconds.
unpauseResumes a paused clock.
delta_secs_f64The time that passed since the previous update, in seconds as a double precision number.
set_relative_speedSets the speed of the clock relative to real time. Errors if `speed` is negative or not finite.
elapsedThe total time that passed since the clock started.
elapsed_secs_wrappedThe total time that passed since the clock started, in seconds, wrapped to a period so it stays prec...
max_deltaThe largest time a single update can add to the clock, longer frames are cut short.
elapsed_secs_f64The total time that passed since the clock started, in seconds as a double precision number.
pauseStops the clock until it is unpaused, the time does not advance while paused.
elapsed_secsThe total time that passed since the clock started, in seconds.
is_pausedWhether the clock is paused.
set_max_deltaSets the largest time a single update can add to the clock.
deltaThe time that passed since the previous update.
relative_speedThe speed of the clock relative to real time, `1` is real time and `2` is twice as fast.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

delta_secs

The time that passed since the previous update, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

unpause

Resumes a paused clock.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

delta_secs_f64

The time that passed since the previous update, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

set_relative_speed

Sets the speed of the clock relative to real time. Errors if speed is negative or not finite.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧
speedF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

elapsed

The total time that passed since the clock started.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

elapsed_secs_wrapped

The total time that passed since the clock started, in seconds, wrapped to a period so it stays precise for long running apps.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

max_delta

The largest time a single update can add to the clock, longer frames are cut short.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

elapsed_secs_f64

The total time that passed since the clock started, in seconds as a double precision number.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF64No Documentation 🚧

pause

Stops the clock until it is unpaused, the time does not advance while paused.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

elapsed_secs

The total time that passed since the clock started, in seconds.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

is_paused

Whether the clock is paused.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

set_max_delta

Sets the largest time a single update can add to the clock.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧
max_deltaDurationNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

delta

The time that passed since the previous update.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnDurationNo Documentation 🚧

relative_speed

The speed of the clock relative to real time, 1 is real time and 2 is twice as fast.

Arguments

NameTypeDocumentation
_selfTime<Virtual>No Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Time<Virtual>>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTime<Virtual>The constructed value.

Fixed

Fixed

Description

The fixed timestep game clock following virtual time.

A specialization of the [Time] structure. For method documentation, see [Time<Fixed>#impl-Time<Fixed>].

It is automatically inserted as a resource by TimePlugin and updated based on Time<Virtual>. The fixed clock is automatically set as the generic [Time] resource during FixedUpdate schedule processing.

The fixed timestep clock advances in fixed-size increments, which is extremely useful for writing logic (like physics) that should have consistent behavior, regardless of framerate.

The default timestep() is 64 hertz, or 15625 microseconds. This value was chosen because using 60 hertz has the potential for a pathological interaction with the monitor refresh rate where the game alternates between running two fixed timesteps and zero fixed timesteps per frame (for example when running two fixed timesteps takes longer than a frame). Additionally, the value is a power of two which losslessly converts into [f32] and [f64].

To run a system on a fixed timestep, add it to one of the [FixedMain] schedules, most commonly FixedUpdate.

This schedule is run a number of times between PreUpdate and Update according to the accumulated overstep() time divided by the timestep(). This means the schedule may run 0, 1 or more times during a single update (which typically corresponds to a rendered frame).

Time<Fixed> and the generic [Time] resource will report a delta() equal to timestep() and always grow elapsed() by one timestep() per iteration.

The fixed timestep clock follows the Time<Virtual> clock, which means it is affected by pause(), set_relative_speed() and set_max_delta() from virtual time. If the virtual clock is paused, the FixedUpdate schedule will not run. It is guaranteed that the elapsed() time in Time<Fixed> is always between the previous elapsed() and the current elapsed() value in Time<Virtual>, so the values are compatible.

Changing the timestep size while the game is running should not normally be done, as having a regular interval is the point of this schedule, but it may be necessary for effects like “bullet-time” if the normal granularity of the fixed timestep is too big for the slowed down time. In this case, set_timestep() and be called to set a new value. The new value will be used immediately for the next run of the FixedUpdate schedule, meaning that it will affect the delta() value for the very next FixedUpdate, even if it is still during the same frame. Any overstep() present in the accumulator will be processed according to the new timestep() value.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Fixed>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFixedThe constructed value.

Real

Real

Description

Real time clock representing elapsed wall clock time.

A specialization of the [Time] structure. For method documentation, see [Time<Real>#impl-Time<Real>].

It is automatically inserted as a resource by TimePlugin and updated with time instants according to TimeUpdateStrategy.1

Note: Using TimeUpdateStrategy::ManualDuration allows for mocking the wall clock for testing purposes. Besides this use case, it is not recommended to do this, as it will no longer represent “wall clock” time as intended.

The delta() and elapsed() values of this clock should be used for anything which deals specifically with real time (wall clock time). It will not be affected by relative game speed adjustments, pausing or other adjustments.1

The clock does not count time from startup() to first_update() into elapsed, but instead will start counting time from the first update call. delta() and elapsed() will report zero on the first update as there is no previous update instant. This means that a delta() of zero must be handled without errors in application logic, as it may theoretically also happen at other times.

[Instant]s for startup(), first_update() and last_update() are recorded and accessible.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

  1. When using TimeUpdateStrategy::ManualDuration, [Time<Real>#impl-Time<Real>] is only a mock of wall clock time. ↩ ↩2

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Real>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRealThe constructed value.

TimerMode

Once

Repeating

Description

Specifies [Timer] behavior.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Once.newNo Documentation 🚧
Repeating.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<TimerMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTimerModeThe constructed value.

Once.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<TimerMode::Once>No Documentation 🚧

Returns

NameTypeDocumentation
returnTimerModeNo Documentation 🚧

Repeating.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<TimerMode::Repeating>No Documentation 🚧

Returns

NameTypeDocumentation
returnTimerModeNo Documentation 🚧

Virtual

Virtual

Description

The virtual game clock representing game time.

A specialization of the [Time] structure. For method documentation, see [Time<Virtual>#impl-Time<Virtual>].

Normally used as Time<Virtual>. It is automatically inserted as a resource by TimePlugin and updated based on Time<Real>. The virtual clock is automatically set as the default generic [Time] resource for the update.

The virtual clock differs from real time clock in that it can be paused, sped up and slowed down. It also limits how much it can advance in a single update in order to prevent unexpected behavior in cases where updates do not happen at regular intervals (e.g. coming back after the program was suspended a long time).

The virtual clock can be paused by calling pause(), unpaused by calling unpause(), or toggled by calling toggle(). When the game clock is paused delta() will be zero on each update, and elapsed() will not grow. effective_speed() will return 0.0. Calling pause() will not affect value the delta() value for the update currently being processed.

The speed of the virtual clock can be changed by calling set_relative_speed(). A value of 2.0 means that virtual clock should advance twice as fast as real time, meaning that delta() values will be double of what Time<Real>::delta() reports and elapsed() will go twice as fast as Time<Real>::elapsed(). Calling set_relative_speed() will not affect the delta() value for the update currently being processed.

The maximum amount of delta time that can be added by a single update can be set by set_max_delta(). This value serves a dual purpose in the virtual clock.

If the game temporarily freezes due to any reason, such as disk access, a blocking system call, or operating system level suspend, reporting the full elapsed delta time is likely to cause bugs in game logic. Usually if a laptop is suspended for an hour, it doesn’t make sense to try to simulate the game logic for the elapsed hour when resuming. Instead it is better to lose the extra time and pretend a shorter duration of time passed. Setting max_delta() to a relatively short time means that the impact on game logic will be minimal.

If the game lags for some reason, meaning that it will take a longer time to compute a frame than the real time that passes during the computation, then we would fall behind in processing virtual time. If this situation persists, and computing a frame takes longer depending on how much virtual time has passed, the game would enter a “death spiral” where computing each frame takes longer and longer and the game will appear to freeze. By limiting the maximum time that can be added at once, we also limit the amount of virtual time the game needs to compute for each frame. This means that the game will run slow, and it will run slower than real time, but it will not freeze and it will recover as soon as computation becomes fast again.

You should set max_delta() to a value that is approximately the minimum FPS your game should have even if heavily lagged for a moment. The actual FPS when lagged will be somewhat lower than this, depending on how much more time it takes to compute a frame compared to real time. You should also consider how stable your FPS is, as the limit will also dictate how big of an FPS drop you can accept without losing time and falling behind real time.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Virtual>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVirtualThe constructed value.

transform

The types and functions in the transform namespace, as returned by import_namespace("transform").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
GlobalTransform[`GlobalTransform`] is an affine transformation from entity-local coordinates to worldspace coordinates. You cannot directly mutate [`GlobalTransform`]...
TransformDescribe the position of an entity. If the entity has a parent, the position is relative to its pa...

GlobalTransform

GlobalTransform

  1. Affine3A

Description

[GlobalTransform] is an affine transformation from entity-local coordinates to worldspace coordinates.

You cannot directly mutate [GlobalTransform]; instead, you change an entity’s transform by manipulating its [Transform], which indirectly causes Bevy to update its [GlobalTransform].

  • To get the global transform of an entity, you should get its [GlobalTransform].
  • For transform hierarchies to work correctly, you must have both a [Transform] and a [GlobalTransform]. [GlobalTransform] is automatically inserted whenever [Transform] is inserted.

[Transform] and [GlobalTransform]

[Transform] transforms an entity relative to its parent’s reference frame, or relative to world space coordinates, if it doesn’t have a ChildOf component.

[GlobalTransform] is managed by Bevy; it is computed by successively applying the [Transform] of each ancestor entity which has a Transform. This is done automatically by Bevy-internal systems in the TransformSystems::Propagate system set.

This system runs during PostUpdate. If you update the [Transform] of an entity in this schedule or after, you will notice a 1 frame lag before the [GlobalTransform] is updated.

Examples

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
rightThe direction to the local right, `+x` in local space.
identityThe identity transform, which maps every point to itself.
scaleThe scale in world space.
to_matrixThe matrix equivalent to this transform.
upThe local up direction, `+y`.
downThe local down direction, `-y`.
translationThe position in world space.
leftThe direction to the local left, `-x` in local space.
mulComposes two transforms when given a global transform, or applies a local transform to this one.
rotationThe rotation in world space.
backThe direction opposite to [`forward`](Self::forward), `+z` in local space.
from_xyzA transform at the position `x`, `y`, `z`, with no rotation and a scale of `1`.
compute_transformThe transform as a [`Transform`](bevy_transform::components::Transform), with the same position, rotation and scale.
forwardThe direction the transform faces, `-z` in local space.
eqWhether both transforms have exactly the same components.
transform_pointApplies the transform to a point in local space, giving its world space position.
reparented_toThe local [`Transform`](bevy_transform::components::Transform) that gives this world transform when parented to `parent`.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

right

The direction to the local right, +x in local space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

identity

The identity transform, which maps every point to itself.

Arguments

Returns

NameTypeDocumentation
returnGlobalTransformNo Documentation 🚧

scale

The scale in world space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

to_matrix

The matrix equivalent to this transform.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

up

The local up direction, +y.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

down

The local down direction, -y.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

translation

The position in world space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

left

The direction to the local left, -x in local space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

mul

Composes two transforms when given a global transform, or applies a local transform to this one.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
rhsGlobalTransformTransform

Returns

NameTypeDocumentation
returnGlobalTransformNo Documentation 🚧

rotation

The rotation in world space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnQuatNo Documentation 🚧

back

The direction opposite to forward, +z in local space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

from_xyz

A transform at the position x, y, z, with no rotation and a scale of 1.

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧
zF32No Documentation 🚧

Returns

NameTypeDocumentation
returnGlobalTransformNo Documentation 🚧

compute_transform

The transform as a Transform, with the same position, rotation and scale.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

forward

The direction the transform faces, -z in local space.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

eq

Whether both transforms have exactly the same components.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
otherGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

transform_point

Applies the transform to a point in local space, giving its world space position.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

reparented_to

The local Transform that gives this world transform when parented to parent.

Arguments

NameTypeDocumentation
_selfGlobalTransformNo Documentation 🚧
parentGlobalTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GlobalTransform>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGlobalTransformThe constructed value.

Transform

Transform

Description

Describe the position of an entity. If the entity has a parent, the position is relative to its parent position.

  • To place or move an entity, you should set its [Transform].
  • To get the global transform of an entity, you should get its [GlobalTransform].
  • To be displayed, an entity must have both a [Transform] and a [GlobalTransform]. [GlobalTransform] is automatically inserted whenever [Transform] is inserted.

Transforms compose from right to left: if t1 and t2 are transforms, then t1 * t2 corresponds to applying t2 first, then applying t1.

[Transform] and [GlobalTransform]

[Transform] is the position of an entity relative to its parent position, or the reference frame if it doesn’t have a ChildOf component.

[GlobalTransform] is the position of an entity relative to the reference frame.

[GlobalTransform] is updated from [Transform] in the TransformSystems::Propagate system set.

This system runs during PostUpdate. If you update the [Transform] of an entity during this set or after, you will notice a 1 frame lag before the [GlobalTransform] is updated.

Examples

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_finiteWhether every component is a finite number.
from_xyzA transform at the position `x`, `y`, `z`. ```multi-lang-example,lua local Transform = import_namespace(“transform”).Transform local t = Transform.from_xyz(1, 2, 3) assert(t.translation.x == 1) `...
from_rotationA transform with the given rotation.
rotate_xRotates this transform by `angle` radians around the x axis.
rotate_yRotates this transform by `angle` radians around the y axis.
rotate_local_zRotates this transform by `angle` radians around its local z axis.
identityThe transform with no translation, no rotation and a scale of `1`.
local_xThe local x axis, as a direction.
looking_atA copy of this transform rotated to face `target`, with `up` as the up direction. Errors if `up` is ...
with_rotationA copy of this transform with a new rotation.
upThe local up direction, `+y`.
backThe direction opposite to [`forward`](Self::forward), `+z` in local space.
translate_aroundMoves this transform around `point` by `rotation`, without changing its rotation.
from_matrixThe transform described by a 4x4 matrix.
rotate_axisRotates this transform by `angle` radians around `axis`. Errors if the axis is zero.
looking_toA copy of this transform rotated to face along `direction`, with `up` as the up direction. Errors if...
rotate_aroundRotates this transform by `rotation` around `point`, moving it along the circle.
leftThe direction to the local left, `-x` in local space.
local_zThe local z axis, as a direction.
rightThe direction to the local right, `+x` in local space.
forwardThe direction the transform faces, `-z` in local space.
with_translationA copy of this transform with a new position.
rotate_local_yRotates this transform by `angle` radians around its local y axis.
look_toRotates this transform to face along `direction`, with `up` as the up direction. Errors if either ve...
downThe local down direction, `-y`.
to_matrixThe matrix equivalent to this transform.
eqWhether both transforms have exactly the same components.
mul_transformComposes this transform with `other`, applying `other` first.
look_atRotates this transform to face `target`, with `up` as the up direction. Errors if `up` is zero.
with_scaleA copy of this transform with a new scale.
local_yThe local y axis, as a direction.
from_scaleA transform with the given scale.
rotate_localRotates this transform by `rotation`, in its own local space.
rotate_local_xRotates this transform by `angle` radians around its local x axis.
rotateRotates this transform by `rotation`, in the parent’s space.
mulComposes two transforms when given a transform, or transforms a point when given a [`Vec3`](bevy_math::Vec3).
from_translationA transform at the given position.
rotate_zRotates this transform by `angle` radians around the z axis.
transform_pointApplies the transform to a point: scales, rotates, then translates it.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

is_finite

Whether every component is a finite number.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

from_xyz

A transform at the position x, y, z.

local Transform = import_namespace("transform").Transform
local t = Transform.from_xyz(1, 2, 3)
assert(t.translation.x == 1)
let Transform = import_namespace("transform").Transform;
let t = Transform.from_xyz(1.0, 2.0, 3.0);
assert!(t.translation.x == 1.0);

Arguments

NameTypeDocumentation
xF32No Documentation 🚧
yF32No Documentation 🚧
zF32No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

from_rotation

A transform with the given rotation.

Arguments

NameTypeDocumentation
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_x

Rotates this transform by angle radians around the x axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rotate_y

Rotates this transform by angle radians around the y axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rotate_local_z

Rotates this transform by angle radians around its local z axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

identity

The transform with no translation, no rotation and a scale of 1.

Arguments

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

local_x

The local x axis, as a direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

looking_at

A copy of this transform rotated to face target, with up as the up direction. Errors if up is zero.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
targetVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

with_rotation

A copy of this transform with a new rotation.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

up

The local up direction, +y.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

back

The direction opposite to forward, +z in local space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

translate_around

Moves this transform around point by rotation, without changing its rotation.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

from_matrix

The transform described by a 4x4 matrix.

Arguments

NameTypeDocumentation
matrixMat4No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_axis

Rotates this transform by angle radians around axis. Errors if the axis is zero.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
axisVec3No Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

looking_to

A copy of this transform rotated to face along direction, with up as the up direction. Errors if either vector is zero.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
directionVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_around

Rotates this transform by rotation around point, moving it along the circle.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

left

The direction to the local left, -x in local space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

local_z

The local z axis, as a direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

right

The direction to the local right, +x in local space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

forward

The direction the transform faces, -z in local space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

with_translation

A copy of this transform with a new position.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_local_y

Rotates this transform by angle radians around its local y axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

look_to

Rotates this transform to face along direction, with up as the up direction. Errors if either vector is zero.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
directionVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

down

The local down direction, -y.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

to_matrix

The matrix equivalent to this transform.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnMat4No Documentation 🚧

eq

Whether both transforms have exactly the same components.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
otherTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

mul_transform

Composes this transform with other, applying other first.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
otherTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

look_at

Rotates this transform to face target, with up as the up direction. Errors if up is zero.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
targetVec3No Documentation 🚧
upVec3No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

with_scale

A copy of this transform with a new scale.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

local_y

The local y axis, as a direction.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

from_scale

A transform with the given scale.

Arguments

NameTypeDocumentation
scaleVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_local

Rotates this transform by rotation, in its own local space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rotate_local_x

Rotates this transform by angle radians around its local x axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

rotate

Rotates this transform by rotation, in the parent’s space.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rotationQuatNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

mul

Composes two transforms when given a transform, or transforms a point when given a Vec3.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
rhsTransformVec3

Returns

NameTypeDocumentation
returnTransformVec3

from_translation

A transform at the given position.

Arguments

NameTypeDocumentation
translationVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnTransformNo Documentation 🚧

rotate_z

Rotates this transform by angle radians around the z axis.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
angleF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

transform_point

Applies the transform to a point: scales, rotates, then translates it.

Arguments

NameTypeDocumentation
_selfTransformNo Documentation 🚧
pointVec3No Documentation 🚧

Returns

NameTypeDocumentation
returnVec3No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Transform>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceTransformThe constructed value.

transform.TransformSystems

The types and functions in the transform.TransformSystems namespace, as returned by import_namespace("transform.TransformSystems").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

Values

NameType
PropagateReflectSystemSet

ui

The types and functions in the ui namespace, as returned by import_namespace("ui").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
UiRectA type which is commonly used to define margins, paddings and borders. # Examples ## Margin A...
ValRepresents the possible value types for layout properties. This enum allows specifying values for...
BorderColorThe border color of the UI node.
BorderRadiusUsed to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners,...
ComputedNodeProvides the computed size and layout properties of a UI [`Node`]. All of the fields are automatically calculated by [`ui_layout_system`](`super::layout::ui_layout_system`)...
OverflowWhether to show or hide overflowing items
ImageNodeA UI Node that renders an image.
CornerRadiusThe horizontal and vertical radii of a rounded corner’s elliptical arc. If one field is auto, the ...
AlignContentUsed to control how items are distributed. - For Flexbox containers, controls alignment of lines i...
AlignItemsUsed to control how each individual item is aligned by default within the space they’re given. - F...
AlignSelfUsed to control how the specified item is aligned within the space it’s given. - For Flexbox items...
BackgroundColorThe background color of the node This serves as the “fill” color.
BoxSizingWhich part of a Node’s box length styles like width and height control See: <https://developer.mo...
DisplayDefines the layout model used by this node. Part of the [`Node`] component.
FlexDirectionDefines how flexbox items are ordered within a flexbox
FlexWrapDefines if flexbox items appear on a single line or on multiple lines
GlobalZIndex`GlobalZIndex` allows a [`Node`] entity anywhere in the UI hierarchy to escape the implicit draw ordering of the UI’s layout tree and be rendered above or below other UI nodes. Root UI nodes without a `GlobalZIndex` component receive an implicit global z-index of `0`. Nodes with a `GlobalZIndex` of greater than 0 will be drawn on top of nodes without a `GlobalZIndex` or nodes with a lower `GlobalZIndex`. Nodes with a `GlobalZIndex` of less than 0 will be drawn below nodes without a `GlobalZIndex` or nodes with a greater `GlobalZIndex`. The order of nodes with the same `GlobalZIndex` is stable between frames. If two Nodes have the same `GlobalZIndex`, ties are decided in order by: * The node with the higher `ZIndex`. * The node that was newly added this frame. * The node with a changed `GlobalZIndex` or `ZIndex`. Otherwise the order is preserved from the previous frame.
GridAutoFlowControls whether grid items are placed row-wise or column-wise as well as whether the sparse or den...
GridPlacementRepresents the position of a grid item in a single axis. There are 3 fields which may be set: ...
GridTrackA [`GridTrack`] is a Row or Column of a CSS Grid. This struct specifies what size the track should be. See below for the different “track sizing functions” you can specify.
GridTrackRepetitionHow many times to repeat a repeated grid track <https://developer.mozilla.org/en-US/docs/Web/CSS/...
InlineDirectionSets the inline axis direction (LTR or RTL) used for layout.
JustifyContentUsed to control how items are distributed. - For Flexbox containers, controls alignment of items i...
JustifyItemsUsed to control how each individual item is aligned by default within the space they’re given. - F...
JustifySelfUsed to control how the specified item is aligned within the space it’s given. - For children of f...
MaxTrackSizingFunctionNo Documentation 🚧
MinTrackSizingFunctionNo Documentation 🚧
NodeThe base component for UI entities. It describes UI layout and style properties. When defining ne...
OutlineThe [`Outline`] component adds an outline outside the edge of a UI node. Outlines do not take up space in the layout. To add an [`Outline`]...
OverflowAxisWhether to show or hide overflowing items
OverflowClipMarginThe bounds of the visible area when a UI node is clipped.
PositionTypeThe strategy used to position this node
RepeatedGridTrackRepresents a *possibly* repeated [`GridTrack`]. The repetition parameter can either be: - The integer `1`, in which case the track is non-repeated. - a `u16` count to repeat the track N times. - A `GridTrackRepetition::AutoFit` or `GridTrackRepetition::AutoFill`. Note: that in the common case you want a non-repeating track (repetition count 1), you may use the constructor methods on [`GridTrack`]...
ResolvedBorderRadiusRepresents the resolved border radii values for a UI node. The values are in physical pixels.
VisualBoxUsed to determine which region of a UI node is used for visual bounds.
ZIndexIndicates that this [`Node`] entity’s front-to-back ordering is not controlled solely by its location in the UI hierarchy. A node with a higher z-index will appear on top of sibling nodes with a lower z-index. UI nodes that have the same z-index will appear according to the order in which they appear in the UI hierarchy. In such a case, the last node to be added to its parent will appear in front of its siblings. Nodes without this component will be treated as if they had a value of [ZIndex]...
NodeImageModeControls how the image is altered to fit within the layout and how the layout algorithm determines ...

Values

NameType
AccessibilityUiSystemsReflectSystemSet

UiRect

UiRect

Description

A type which is commonly used to define margins, paddings and borders.

Examples

Margin

A margin is used to create space around UI elements, outside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let margin = UiRect::all(Val::Auto); // Centers the UI element

Padding

A padding is used to create space around UI elements, inside of any defined borders.

# use bevy_ui::{UiRect, Val};
#
let padding = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Borders

A border is used to define the width of the border of a UI element.

# use bevy_ui::{UiRect, Val};
#
let border = UiRect {
    left: Val::Px(10.0),
    right: Val::Px(20.0),
    top: Val::Px(30.0),
    bottom: Val::Px(40.0),
};

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
verticalA rectangle with the length on its top and bottom sides only.
allA rectangle with the same length on all four sides.
zeroA rectangle with no space on any side.
pxA rectangle with lengths in logical pixels for its left, right, top and bottom sides.
horizontalA rectangle with the length on its left and right sides only.
percentA rectangle with percentages of the parent for its left, right, top and bottom sides.
axesA rectangle with one length for the left and right sides and another for the top and bottom.
newA rectangle with a length for each of its left, right, top and bottom sides.

vertical

A rectangle with the length on its top and bottom sides only.

Arguments

NameTypeDocumentation
valueValNo Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

all

A rectangle with the same length on all four sides.

Arguments

NameTypeDocumentation
valueValNo Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

zero

A rectangle with no space on any side.

Arguments

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

px

A rectangle with lengths in logical pixels for its left, right, top and bottom sides.

Arguments

NameTypeDocumentation
leftF32No Documentation 🚧
rightF32No Documentation 🚧
topF32No Documentation 🚧
bottomF32No Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

horizontal

A rectangle with the length on its left and right sides only.

Arguments

NameTypeDocumentation
valueValNo Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

percent

A rectangle with percentages of the parent for its left, right, top and bottom sides.

Arguments

NameTypeDocumentation
leftF32No Documentation 🚧
rightF32No Documentation 🚧
topF32No Documentation 🚧
bottomF32No Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

axes

A rectangle with one length for the left and right sides and another for the top and bottom.

Arguments

NameTypeDocumentation
horizontalValNo Documentation 🚧
verticalValNo Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

new

A rectangle with a length for each of its left, right, top and bottom sides.

Arguments

NameTypeDocumentation
leftValNo Documentation 🚧
rightValNo Documentation 🚧
topValNo Documentation 🚧
bottomValNo Documentation 🚧

Returns

NameTypeDocumentation
returnUiRectNo Documentation 🚧

Val

Auto

Px

  1. F32

Percent

  1. F32

Vw

  1. F32

Vh

  1. F32

VMin

  1. F32

VMax

  1. F32

Em

  1. F32

Rem

  1. F32

Description

Represents the possible value types for layout properties.

This enum allows specifying values for various Node properties in different units, such as logical pixels, percentages, or automatically determined values.

Val also implements [core::str::FromStr] to allow parsing values from strings in the format #.#px. Whitespaces between the value and unit is allowed. The following units are supported:

  • px: logical pixels
  • %: percentage
  • vw: percentage of the viewport width
  • vh: percentage of the viewport height
  • vmin: percentage of the viewport’s smaller dimension
  • vmax: percentage of the viewport’s larger dimension

Additionally, auto will be parsed as [Val::Auto].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
autoA length that the layout works out from the node and its contents.
vwA length as a percentage of the viewport width.
pxA length in logical pixels, such as `Val.px(100)` for 100 pixels. ```multi-lang-example,lua local Node = import_namespace(“ui”).Node local Val = import_namespace(“ui”).Val local node = Node.new({ width = Val.px(100) }) assert(node.width[1] == 100) ``` ```multi-lang-example,rune let Node = import_namespace(“ui”).Node; let Val = import_namespace(“ui”).Val; let node = Node.new(#{ width: Val.px(100.0) }); assert!(node.width[0]...
vmaxA length as a percentage of the viewport’s larger dimension.
vhA length as a percentage of the viewport height.
vminA length as a percentage of the viewport’s smaller dimension.
percentA length as a percentage of the parent’s size along the axis it applies to.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Em.newNo Documentation 🚧
Percent.newNo Documentation 🚧
Px.newNo Documentation 🚧
Rem.newNo Documentation 🚧
VMax.newNo Documentation 🚧
VMin.newNo Documentation 🚧
Vh.newNo Documentation 🚧
Vw.newNo Documentation 🚧

auto

A length that the layout works out from the node and its contents.

Arguments

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

vw

A length as a percentage of the viewport width.

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

px

A length in logical pixels, such as Val.px(100) for 100 pixels.

local Node = import_namespace("ui").Node
local Val = import_namespace("ui").Val
local node = Node.new({ width = Val.px(100) })
assert(node.width[1] == 100)
let Node = import_namespace("ui").Node;
let Val = import_namespace("ui").Val;
let node = Node.new(#{ width: Val.px(100.0) });
assert!(node.width[0] == 100.0);

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

vmax

A length as a percentage of the viewport’s larger dimension.

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

vh

A length as a percentage of the viewport height.

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

vmin

A length as a percentage of the viewport’s smaller dimension.

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

percent

A length as a percentage of the parent’s size along the axis it applies to.

Arguments

NameTypeDocumentation
valueF32No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Val>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceValThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Em.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Em>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Percent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Percent>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Px.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Px>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Rem.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Rem>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

VMax.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::VMax>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

VMin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::VMin>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Vh.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Vh>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

Vw.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Val::Vw>No Documentation 🚧

Returns

NameTypeDocumentation
returnValNo Documentation 🚧

BorderColor

BorderColor

Description

The border color of the UI node.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
allA border with the same color on all four sides.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

all

A border with the same color on all four sides.

Arguments

NameTypeDocumentation
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnBorderColorNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BorderColor>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBorderColorThe constructed value.

BorderRadius

BorderRadius

Description

Used to add rounded corners to a UI node. You can set a UI node to have uniformly rounded corners, elliptical corners, or specify a different radius for each corner. If a given radius exceeds half the length of the node’s height or width, the radius will be calculated as half the height or width.

Percentage horizontal and vertical values are based on the node’s width and height, respectively.

Example

#![allow(unused)]
fn main() {
use bevy_ecs::prelude::*;
use bevy_ui::prelude::*;
use bevy_color::palettes::basic::{BLUE};
fn setup_ui(mut commands: Commands) {
    commands.spawn((
        Node {
            width: Val::Px(100.),
            height: Val::Px(100.),
            border: UiRect::all(Val::Px(2.)),
            border_radius: BorderRadius {
                // rounded corners, x and y radii equal
                top_left: CornerRadius::circular(px(10.)),
                top_right: percent(20.).into(),
                // elliptical corner
                bottom_right: CornerRadius::new(px(30.), px(20.)),
                bottom_left: CornerRadius { x: px(10.), y: px(40.) },
            },
            ..Default::default()
        },
        BackgroundColor(BLUE.into()),
    ));
}
}

https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
pxEach corner rounded by a length in logical pixels, in the order top left, top right, bottom right, b...
maxThe most rounding possible, which makes the node a capsule, or a circle if it is square.
allEvery corner rounded by the same length.
percentEach corner rounded by a percentage, in the order top left, top right, bottom right, bottom left.
zeroNo rounding, so every corner is a right angle.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

px

Each corner rounded by a length in logical pixels, in the order top left, top right, bottom right, bottom left.

Arguments

NameTypeDocumentation
top_leftF32No Documentation 🚧
top_rightF32No Documentation 🚧
bottom_rightF32No Documentation 🚧
bottom_leftF32No Documentation 🚧

Returns

NameTypeDocumentation
returnBorderRadiusNo Documentation 🚧

max

The most rounding possible, which makes the node a capsule, or a circle if it is square.

Arguments

Returns

NameTypeDocumentation
returnBorderRadiusNo Documentation 🚧

all

Every corner rounded by the same length.

Arguments

NameTypeDocumentation
radiusValNo Documentation 🚧

Returns

NameTypeDocumentation
returnBorderRadiusNo Documentation 🚧

percent

Each corner rounded by a percentage, in the order top left, top right, bottom right, bottom left.

Arguments

NameTypeDocumentation
top_leftF32No Documentation 🚧
top_rightF32No Documentation 🚧
bottom_rightF32No Documentation 🚧
bottom_leftF32No Documentation 🚧

Returns

NameTypeDocumentation
returnBorderRadiusNo Documentation 🚧

zero

No rounding, so every corner is a right angle.

Arguments

Returns

NameTypeDocumentation
returnBorderRadiusNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BorderRadius>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBorderRadiusThe constructed value.

ComputedNode

ComputedNode

Description

Provides the computed size and layout properties of a UI [Node].

All of the fields are automatically calculated by ui_layout_system during PostUpdate in the UiSystems::Layout set.

The fields are measured in physical pixels. You can multiply by the inverse_scale_factor field to convert back to logical pixels.

Fields in this struct are public but should only rarely be directly modified. For example, in a scrollbar you may want to derive the handle’s size from the proportion of scrollable content in-view. You can directly modify ComputedNode after layout to set the handle size without a frame delay.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
is_emptyWhether the node has no width or no height, so that nothing is drawn for it.
sizeThe width and height of the node in physical pixels, as calculated by the last layout.
content_sizeThe width and height of the node’s content in physical pixels, as calculated by the last layout.
inverse_scale_factorThe factor that turns physical pixels into logical pixels for this node.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

is_empty

Whether the node has no width or no height, so that nothing is drawn for it.

Arguments

NameTypeDocumentation
_selfComputedNodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

size

The width and height of the node in physical pixels, as calculated by the last layout.

Arguments

NameTypeDocumentation
_selfComputedNodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

content_size

The width and height of the node’s content in physical pixels, as calculated by the last layout.

Arguments

NameTypeDocumentation
_selfComputedNodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

inverse_scale_factor

The factor that turns physical pixels into logical pixels for this node.

Arguments

NameTypeDocumentation
_selfComputedNodeNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ComputedNode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceComputedNodeThe constructed value.

Overflow

Overflow

Description

Whether to show or hide overflowing items

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
clipContent that overflows the node is clipped on both axes.
hiddenContent that overflows the node is hidden on both axes, with the layout making room for it to be cut...
clip_yContent that overflows the node is clipped on the vertical axis only.
clip_xContent that overflows the node is clipped on the horizontal axis only.
visibleContent that overflows the node is shown.
scrollContent that overflows the node can be scrolled on both axes.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

clip

Content that overflows the node is clipped on both axes.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

hidden

Content that overflows the node is hidden on both axes, with the layout making room for it to be cut off.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

clip_y

Content that overflows the node is clipped on the vertical axis only.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

clip_x

Content that overflows the node is clipped on the horizontal axis only.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

visible

Content that overflows the node is shown.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

scroll

Content that overflows the node can be scrolled on both axes.

Arguments

Returns

NameTypeDocumentation
returnOverflowNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Overflow>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOverflowThe constructed value.

ImageNode

ImageNode

Description

A UI Node that renders an image.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
with_colorA copy of the node that tints its image with `color`.
newA node that draws the given [`Image`](bevy_image::Image), untinted.

with_color

A copy of the node that tints its image with color.

Arguments

NameTypeDocumentation
_selfImageNodeNo Documentation 🚧
colorColorNo Documentation 🚧

Returns

NameTypeDocumentation
returnImageNodeNo Documentation 🚧

new

A node that draws the given Image, untinted.

Arguments

NameTypeDocumentation
imageHandle<Image>No Documentation 🚧

Returns

NameTypeDocumentation
returnImageNodeNo Documentation 🚧

CornerRadius

CornerRadius

Description

The horizontal and vertical radii of a rounded corner’s elliptical arc. If one field is auto, the resolved radius will be circular and clamped to half the length of the node’s shortest side. If either field is zero, or both are auto, the node will have square corners.

Example

# use bevy_math::{Vec2, Vec2Swizzles};
# use bevy_ui::{CornerRadius, Val};
# use bevy_text::{EmSize, RemSize};
let radius = Val::Px(10.0);
let size = Vec2::new(100.0, 50.0);
let viewport_size = Vec2::new(1920.0, 1080.0);
let em_size = EmSize(20.0);
let rem_size = RemSize(20.0);

let c1 = CornerRadius {
    x: radius,
    y: Val::ZERO,
};
let c2 = CornerRadius {
    x: Val::ZERO,
    y: radius,
};
let r = c1.resolve(1.0, size, viewport_size, em_size, rem_size);
assert_eq!(
    r,
    c2.resolve(1.0, size, viewport_size, em_size, rem_size).yx(),
);
assert_eq!(
    r,
    Vec2::new(10.0, 0.0),
);

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<CornerRadius>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCornerRadiusThe constructed value.

AlignContent

Default

Start

StartSafe

End

EndSafe

FlexStart

FlexStartSafe

FlexEnd

FlexEndSafe

Center

CenterSafe

Stretch

SpaceBetween

SpaceEvenly

SpaceAround

Description

Used to control how items are distributed.

  • For Flexbox containers, controls alignment of lines if flex_wrap is set to [FlexWrap::Wrap] and there are multiple lines of items.
  • For CSS Grid containers, controls alignment of grid rows.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-content

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
Default.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
FlexEnd.newNo Documentation 🚧
FlexEndSafe.newNo Documentation 🚧
FlexStart.newNo Documentation 🚧
FlexStartSafe.newNo Documentation 🚧
SpaceAround.newNo Documentation 🚧
SpaceBetween.newNo Documentation 🚧
SpaceEvenly.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AlignContent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAlignContentThe constructed value.

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

Default.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::Default>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

FlexEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::FlexEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

FlexEndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::FlexEndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

FlexStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::FlexStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

FlexStartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::FlexStartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

SpaceAround.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::SpaceAround>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

SpaceBetween.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::SpaceBetween>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

SpaceEvenly.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::SpaceEvenly>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignContent::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignContentNo Documentation 🚧

AlignItems

Default

Start

StartSafe

End

EndSafe

FlexStart

FlexStartSafe

FlexEnd

FlexEndSafe

Center

CenterSafe

Baseline

Stretch

Description

Used to control how each individual item is aligned by default within the space they’re given.

  • For Flexbox containers, sets default cross axis alignment of the child items.
  • For CSS Grid containers, controls block (vertical) axis alignment of children of this grid container within their grid areas.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-items

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Baseline.newNo Documentation 🚧
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
Default.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
FlexEnd.newNo Documentation 🚧
FlexEndSafe.newNo Documentation 🚧
FlexStart.newNo Documentation 🚧
FlexStartSafe.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AlignItems>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAlignItemsThe constructed value.

Baseline.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::Baseline>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

Default.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::Default>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

FlexEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::FlexEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

FlexEndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::FlexEndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

FlexStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::FlexStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

FlexStartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::FlexStartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignItems::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignItemsNo Documentation 🚧

AlignSelf

Auto

Start

StartSafe

End

EndSafe

FlexStart

FlexStartSafe

FlexEnd

FlexEndSafe

Center

CenterSafe

Baseline

Stretch

Description

Used to control how the specified item is aligned within the space it’s given.

  • For Flexbox items, controls cross axis alignment of the item.
  • For CSS Grid items, controls block (vertical) axis alignment of a grid item within its grid area.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/align-self

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Baseline.newNo Documentation 🚧
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
FlexEnd.newNo Documentation 🚧
FlexEndSafe.newNo Documentation 🚧
FlexStart.newNo Documentation 🚧
FlexStartSafe.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<AlignSelf>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceAlignSelfThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

Baseline.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::Baseline>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

FlexEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::FlexEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

FlexEndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::FlexEndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

FlexStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::FlexStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

FlexStartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::FlexStartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<AlignSelf::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnAlignSelfNo Documentation 🚧

BackgroundColor

BackgroundColor

  1. Color

Description

The background color of the node

This serves as the “fill” color.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BackgroundColor>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBackgroundColorThe constructed value.

BoxSizing

BorderBox

ContentBox

Description

Which part of a Node’s box length styles like width and height control

See: https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
BorderBox.newNo Documentation 🚧
ContentBox.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BoxSizing>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBoxSizingThe constructed value.

BorderBox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<BoxSizing::BorderBox>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoxSizingNo Documentation 🚧

ContentBox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<BoxSizing::ContentBox>No Documentation 🚧

Returns

NameTypeDocumentation
returnBoxSizingNo Documentation 🚧

Display

Flex

Grid

Block

None

Description

Defines the layout model used by this node.

Part of the [Node] component.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Block.newNo Documentation 🚧
Flex.newNo Documentation 🚧
Grid.newNo Documentation 🚧
None.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Display>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDisplayThe constructed value.

Block.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Display::Block>No Documentation 🚧

Returns

NameTypeDocumentation
returnDisplayNo Documentation 🚧

Flex.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Display::Flex>No Documentation 🚧

Returns

NameTypeDocumentation
returnDisplayNo Documentation 🚧

Grid.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Display::Grid>No Documentation 🚧

Returns

NameTypeDocumentation
returnDisplayNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<Display::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnDisplayNo Documentation 🚧

FlexDirection

Row

Column

RowReverse

ColumnReverse

Description

Defines how flexbox items are ordered within a flexbox

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Column.newNo Documentation 🚧
ColumnReverse.newNo Documentation 🚧
Row.newNo Documentation 🚧
RowReverse.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FlexDirection>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFlexDirectionThe constructed value.

Column.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexDirection::Column>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexDirectionNo Documentation 🚧

ColumnReverse.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexDirection::ColumnReverse>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexDirectionNo Documentation 🚧

Row.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexDirection::Row>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexDirectionNo Documentation 🚧

RowReverse.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexDirection::RowReverse>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexDirectionNo Documentation 🚧

FlexWrap

NoWrap

Wrap

WrapReverse

Description

Defines if flexbox items appear on a single line or on multiple lines

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
NoWrap.newNo Documentation 🚧
Wrap.newNo Documentation 🚧
WrapReverse.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FlexWrap>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFlexWrapThe constructed value.

NoWrap.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexWrap::NoWrap>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexWrapNo Documentation 🚧

Wrap.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexWrap::Wrap>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexWrapNo Documentation 🚧

WrapReverse.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<FlexWrap::WrapReverse>No Documentation 🚧

Returns

NameTypeDocumentation
returnFlexWrapNo Documentation 🚧

GlobalZIndex

GlobalZIndex

  1. I32

Description

GlobalZIndex allows a [Node] entity anywhere in the UI hierarchy to escape the implicit draw ordering of the UI’s layout tree and be rendered above or below other UI nodes. Root UI nodes without a GlobalZIndex component receive an implicit global z-index of 0. Nodes with a GlobalZIndex of greater than 0 will be drawn on top of nodes without a GlobalZIndex or nodes with a lower GlobalZIndex. Nodes with a GlobalZIndex of less than 0 will be drawn below nodes without a GlobalZIndex or nodes with a greater GlobalZIndex. The order of nodes with the same GlobalZIndex is stable between frames.

If two Nodes have the same GlobalZIndex, ties are decided in order by:

  • The node with the higher ZIndex.
  • The node that was newly added this frame.
  • The node with a changed GlobalZIndex or ZIndex.

Otherwise the order is preserved from the previous frame.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GlobalZIndex>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGlobalZIndexThe constructed value.

GridAutoFlow

Row

Column

RowDense

ColumnDense

Description

Controls whether grid items are placed row-wise or column-wise as well as whether the sparse or dense packing algorithm is used.

The “dense” packing algorithm attempts to fill in holes earlier in the grid, if smaller items come up later. This may cause items to appear out-of-order when doing so would fill in holes left by larger items.

Defaults to [GridAutoFlow::Row].

https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Column.newNo Documentation 🚧
ColumnDense.newNo Documentation 🚧
Row.newNo Documentation 🚧
RowDense.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GridAutoFlow>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGridAutoFlowThe constructed value.

Column.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridAutoFlow::Column>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridAutoFlowNo Documentation 🚧

ColumnDense.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridAutoFlow::ColumnDense>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridAutoFlowNo Documentation 🚧

Row.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridAutoFlow::Row>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridAutoFlowNo Documentation 🚧

RowDense.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridAutoFlow::RowDense>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridAutoFlowNo Documentation 🚧

GridPlacement

GridPlacement

Description

Represents the position of a grid item in a single axis.

There are 3 fields which may be set:

  • start: which grid line the item should start at
  • end: which grid line the item should end at
  • span: how many tracks the item should span

The default span is 1. If neither start or end is set then the item will be placed automatically.

Generally, at most two fields should be set. If all three fields are specified then span will be ignored. If end specifies an earlier grid line than start then end will be ignored and the item will have a span of 1.

https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Line-based_Placement_with_CSS_Grid

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GridPlacement>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGridPlacementThe constructed value.

GridTrack

GridTrack

Description

A [GridTrack] is a Row or Column of a CSS Grid. This struct specifies what size the track should be. See below for the different “track sizing functions” you can specify.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GridTrack>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGridTrackThe constructed value.

GridTrackRepetition

Count

  1. U16

AutoFill

AutoFit

Description

How many times to repeat a repeated grid track

https://developer.mozilla.org/en-US/docs/Web/CSS/repeat

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AutoFill.newNo Documentation 🚧
AutoFit.newNo Documentation 🚧
Count.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<GridTrackRepetition>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceGridTrackRepetitionThe constructed value.

AutoFill.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridTrackRepetition::AutoFill>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridTrackRepetitionNo Documentation 🚧

AutoFit.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridTrackRepetition::AutoFit>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridTrackRepetitionNo Documentation 🚧

Count.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<GridTrackRepetition::Count>No Documentation 🚧

Returns

NameTypeDocumentation
returnGridTrackRepetitionNo Documentation 🚧

InlineDirection

Ltr

Rtl

Description

Sets the inline axis direction (LTR or RTL) used for layout.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Ltr.newNo Documentation 🚧
Rtl.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InlineDirection>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInlineDirectionThe constructed value.

Ltr.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<InlineDirection::Ltr>No Documentation 🚧

Returns

NameTypeDocumentation
returnInlineDirectionNo Documentation 🚧

Rtl.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<InlineDirection::Rtl>No Documentation 🚧

Returns

NameTypeDocumentation
returnInlineDirectionNo Documentation 🚧

JustifyContent

Default

Start

StartSafe

End

EndSafe

FlexStart

FlexStartSafe

FlexEnd

FlexEndSafe

Center

CenterSafe

Stretch

SpaceBetween

SpaceEvenly

SpaceAround

Description

Used to control how items are distributed.

  • For Flexbox containers, controls alignment of items in the main axis.
  • For CSS Grid containers, controls alignment of grid columns.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
Default.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
FlexEnd.newNo Documentation 🚧
FlexEndSafe.newNo Documentation 🚧
FlexStart.newNo Documentation 🚧
FlexStartSafe.newNo Documentation 🚧
SpaceAround.newNo Documentation 🚧
SpaceBetween.newNo Documentation 🚧
SpaceEvenly.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JustifyContent>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJustifyContentThe constructed value.

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

Default.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::Default>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

FlexEnd.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::FlexEnd>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

FlexEndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::FlexEndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

FlexStart.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::FlexStart>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

FlexStartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::FlexStartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

SpaceAround.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::SpaceAround>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

SpaceBetween.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::SpaceBetween>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

SpaceEvenly.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::SpaceEvenly>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyContent::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyContentNo Documentation 🚧

JustifyItems

Default

Start

StartSafe

End

EndSafe

Center

CenterSafe

Baseline

Stretch

Description

Used to control how each individual item is aligned by default within the space they’re given.

  • For Flexbox containers, this property has no effect. See justify_content for main axis alignment of flex items.
  • For CSS Grid containers, sets default inline (horizontal) axis alignment of child items within their grid areas.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-items

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Baseline.newNo Documentation 🚧
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
Default.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JustifyItems>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJustifyItemsThe constructed value.

Baseline.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::Baseline>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

Default.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::Default>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifyItems::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifyItemsNo Documentation 🚧

JustifySelf

Auto

Start

StartSafe

End

EndSafe

Center

CenterSafe

Baseline

Stretch

Description

Used to control how the specified item is aligned within the space it’s given.

  • For children of flex nodes, this property has no effect. See justify_content for main axis alignment of flex items.
  • For CSS Grid items, controls inline (horizontal) axis alignment of a grid item within its grid area.

Safe alignments

Safe alignments will fall back to [Self::Start] if aligning the items would overflow the container, so the start of the content stays visible.

https://developer.mozilla.org/en-US/docs/Web/CSS/justify-self

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Baseline.newNo Documentation 🚧
Center.newNo Documentation 🚧
CenterSafe.newNo Documentation 🚧
End.newNo Documentation 🚧
EndSafe.newNo Documentation 🚧
Start.newNo Documentation 🚧
StartSafe.newNo Documentation 🚧
Stretch.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<JustifySelf>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceJustifySelfThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

Baseline.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::Baseline>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

Center.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::Center>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

CenterSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::CenterSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

End.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::End>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

EndSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::EndSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

Start.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::Start>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

StartSafe.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::StartSafe>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<JustifySelf::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnJustifySelfNo Documentation 🚧

MaxTrackSizingFunction

Px

  1. F32

Percent

  1. F32

Em

  1. F32

Rem

  1. F32

MinContent

MaxContent

FitContentPx

  1. F32

FitContentPercent

  1. F32

Auto

Fraction

  1. F32

VMin

  1. F32

VMax

  1. F32

Vh

  1. F32

Vw

  1. F32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Em.newNo Documentation 🚧
FitContentPercent.newNo Documentation 🚧
FitContentPx.newNo Documentation 🚧
Fraction.newNo Documentation 🚧
MaxContent.newNo Documentation 🚧
MinContent.newNo Documentation 🚧
Percent.newNo Documentation 🚧
Px.newNo Documentation 🚧
Rem.newNo Documentation 🚧
VMax.newNo Documentation 🚧
VMin.newNo Documentation 🚧
Vh.newNo Documentation 🚧
Vw.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MaxTrackSizingFunction>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMaxTrackSizingFunctionThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Em.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Em>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

FitContentPercent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::FitContentPercent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

FitContentPx.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::FitContentPx>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Fraction.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Fraction>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

MaxContent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::MaxContent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

MinContent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::MinContent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Percent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Percent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Px.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Px>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Rem.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Rem>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

VMax.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::VMax>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

VMin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::VMin>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Vh.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Vh>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

Vw.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MaxTrackSizingFunction::Vw>No Documentation 🚧

Returns

NameTypeDocumentation
returnMaxTrackSizingFunctionNo Documentation 🚧

MinTrackSizingFunction

Px

  1. F32

Percent

  1. F32

Em

  1. F32

Rem

  1. F32

MinContent

MaxContent

Auto

VMin

  1. F32

VMax

  1. F32

Vh

  1. F32

Vw

  1. F32

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Em.newNo Documentation 🚧
MaxContent.newNo Documentation 🚧
MinContent.newNo Documentation 🚧
Percent.newNo Documentation 🚧
Px.newNo Documentation 🚧
Rem.newNo Documentation 🚧
VMax.newNo Documentation 🚧
VMin.newNo Documentation 🚧
Vh.newNo Documentation 🚧
Vw.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MinTrackSizingFunction>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMinTrackSizingFunctionThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Em.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Em>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

MaxContent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::MaxContent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

MinContent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::MinContent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Percent.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Percent>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Px.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Px>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Rem.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Rem>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

VMax.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::VMax>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

VMin.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::VMin>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Vh.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Vh>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Vw.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MinTrackSizingFunction::Vw>No Documentation 🚧

Returns

NameTypeDocumentation
returnMinTrackSizingFunctionNo Documentation 🚧

Node

Node

Description

The base component for UI entities. It describes UI layout and style properties.

When defining new types of UI entities, require [Node] to make them behave like UI nodes.

Nodes can be laid out using either Flexbox or CSS Grid Layout.

See below for general learning resources and for documentation on the individual style properties.

Flexbox

CSS Grid

See also

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Node>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNodeThe constructed value.

Outline

Outline

Description

The [Outline] component adds an outline outside the edge of a UI node. Outlines do not take up space in the layout.

To add an [Outline] to a UI node you can spawn a (Node, Outline) tuple bundle:

# use bevy_ecs::prelude::*;
# use bevy_ui::prelude::*;
# use bevy_color::palettes::basic::{RED, BLUE};
fn setup_ui(mut commands: Commands) {
    commands.spawn((
        Node {
            width: Val::Px(100.),
            height: Val::Px(100.),
            ..Default::default()
        },
        BackgroundColor(BLUE.into()),
        Outline::new(Val::Px(10.), Val::ZERO, RED.into())
    ));
}

[Outline] components can also be added later to existing UI nodes:

# use bevy_ecs::prelude::*;
# use bevy_ui::prelude::*;
# use bevy_picking::hover::Hovered;
# use bevy_color::Color;
fn outline_hovered_button_system(
    mut commands: Commands,
    mut node_query: Query<(Entity, &Hovered, Option<&mut Outline>), Changed<Hovered>>,
) {
    for (entity, hovered, mut maybe_outline) in node_query.iter_mut() {
        let outline_color =
            if hovered.get() {
                Color::WHITE
            } else {
                Color::NONE
            };
        if let Some(mut outline) = maybe_outline {
            outline.color = outline_color;
        } else {
            commands.entity(entity).insert(Outline::new(Val::Px(10.), Val::ZERO, outline_color));
        }
    }
}

Inserting and removing an [Outline] component repeatedly will result in table moves, so it is generally preferable to set Outline::color to [Color::NONE] to hide an outline.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Outline>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOutlineThe constructed value.

OverflowAxis

Visible

Clip

Hidden

Scroll

Description

Whether to show or hide overflowing items

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Clip.newNo Documentation 🚧
Hidden.newNo Documentation 🚧
Scroll.newNo Documentation 🚧
Visible.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<OverflowAxis>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOverflowAxisThe constructed value.

Clip.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OverflowAxis::Clip>No Documentation 🚧

Returns

NameTypeDocumentation
returnOverflowAxisNo Documentation 🚧

Hidden.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OverflowAxis::Hidden>No Documentation 🚧

Returns

NameTypeDocumentation
returnOverflowAxisNo Documentation 🚧

Scroll.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OverflowAxis::Scroll>No Documentation 🚧

Returns

NameTypeDocumentation
returnOverflowAxisNo Documentation 🚧

Visible.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<OverflowAxis::Visible>No Documentation 🚧

Returns

NameTypeDocumentation
returnOverflowAxisNo Documentation 🚧

OverflowClipMargin

OverflowClipMargin

Description

The bounds of the visible area when a UI node is clipped.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<OverflowClipMargin>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceOverflowClipMarginThe constructed value.

PositionType

Relative

Absolute

Description

The strategy used to position this node

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Absolute.newNo Documentation 🚧
Relative.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<PositionType>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referencePositionTypeThe constructed value.

Absolute.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PositionType::Absolute>No Documentation 🚧

Returns

NameTypeDocumentation
returnPositionTypeNo Documentation 🚧

Relative.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PositionType::Relative>No Documentation 🚧

Returns

NameTypeDocumentation
returnPositionTypeNo Documentation 🚧

RepeatedGridTrack

RepeatedGridTrack

Description

Represents a possibly repeated [GridTrack].

The repetition parameter can either be:

  • The integer 1, in which case the track is non-repeated.
  • a u16 count to repeat the track N times.
  • A GridTrackRepetition::AutoFit or GridTrackRepetition::AutoFill.

Note: that in the common case you want a non-repeating track (repetition count 1), you may use the constructor methods on [GridTrack] to create a RepeatedGridTrack. i.e. GridTrack::px(10.0) is equivalent to RepeatedGridTrack::px(1, 10.0).

You may only use one auto-repetition per track list. And if your track list contains an auto repetition then all tracks (in and outside of the repetition) must be fixed size (px or percent). Integer repetitions are just shorthand for writing out N tracks longhand and are not subject to the same limitations.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<RepeatedGridTrack>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceRepeatedGridTrackThe constructed value.

ResolvedBorderRadius

ResolvedBorderRadius

Description

Represents the resolved border radii values for a UI node.

The values are in physical pixels.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ResolvedBorderRadius>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceResolvedBorderRadiusThe constructed value.

VisualBox

ContentBox

PaddingBox

BorderBox

Description

Used to determine which region of a UI node is used for visual bounds.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
BorderBox.newNo Documentation 🚧
ContentBox.newNo Documentation 🚧
PaddingBox.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<VisualBox>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVisualBoxThe constructed value.

BorderBox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<VisualBox::BorderBox>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisualBoxNo Documentation 🚧

ContentBox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<VisualBox::ContentBox>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisualBoxNo Documentation 🚧

PaddingBox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<VisualBox::PaddingBox>No Documentation 🚧

Returns

NameTypeDocumentation
returnVisualBoxNo Documentation 🚧

ZIndex

ZIndex

  1. I32

Description

Indicates that this [Node] entity’s front-to-back ordering is not controlled solely by its location in the UI hierarchy. A node with a higher z-index will appear on top of sibling nodes with a lower z-index.

UI nodes that have the same z-index will appear according to the order in which they appear in the UI hierarchy. In such a case, the last node to be added to its parent will appear in front of its siblings.

Nodes without this component will be treated as if they had a value of [ZIndex][ZIndex](0).

Use [GlobalZIndex] if you need to order separate UI hierarchies or nodes that are not siblings in a given UI hierarchy.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ZIndex>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceZIndexThe constructed value.

NodeImageMode

Auto

Stretch

Sliced

  1. TextureSlicer

Tiled

Description

Controls how the image is altered to fit within the layout and how the layout algorithm determines the space in the layout for the image

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Sliced.newNo Documentation 🚧
Stretch.newNo Documentation 🚧
Tiled.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<NodeImageMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceNodeImageModeThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NodeImageMode::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnNodeImageModeNo Documentation 🚧

Sliced.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NodeImageMode::Sliced>No Documentation 🚧

Returns

NameTypeDocumentation
returnNodeImageModeNo Documentation 🚧

Stretch.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NodeImageMode::Stretch>No Documentation 🚧

Returns

NameTypeDocumentation
returnNodeImageModeNo Documentation 🚧

Tiled.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<NodeImageMode::Tiled>No Documentation 🚧

Returns

NameTypeDocumentation
returnNodeImageModeNo Documentation 🚧

ui.UiSystems

The types and functions in the ui.UiSystems namespace, as returned by import_namespace("ui.UiSystems").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

Values

uuid

The types and functions in the uuid namespace, as returned by import_namespace("uuid").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
UuidNo Documentation 🚧

Uuid

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Uuid>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceUuidThe constructed value.

wgpu_types

The types and functions in the wgpu_types namespace, as returned by import_namespace("wgpu_types").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
BlendStateNo Documentation 🚧

BlendState

Opaque Type. 🔒

Description

No Documentation 🚧

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<BlendState>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBlendStateThe constructed value.

window

The types and functions in the window namespace, as returned by import_namespace("window").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
WindowThe defining [`Component`] for window entities, storing information about how it should appear and behave. Each window corresponds to an entity, and is uniquely identified by the value of their [`Entity`]...
WindowResolutionControls the size of a [`Window`] ## Physical, logical and requested sizes There are three sizes associated with a window: - the physical size, which represents the actual height and width in physical pixels the window occupies on the monitor, - the logical size, which represents the size that should be used to scale elements inside the window, measured in logical pixels, - the requested size, measured in logical pixels, which is the value submitted to the API when creating the window, or requesting that it be resized. ## Scale factor The reason logical size and physical size are separated and can be different is to account for the cases where: - several monitors have different pixel densities, - the user has set up a pixel density preference in its operating system, - the Bevy `App` has specified a specific scale factor between both. The factor between physical size and logical size can be retrieved with [`WindowResolution::scale_factor`]...
VideoModeRepresents a video mode that a monitor supports
CompositeAlphaModeSpecifies how the alpha channel of the textures should be handled during compositing, for a [`Window`]...
EnabledButtonsSpecifies which [`Window`] control buttons should be enabled. ## Platform-specific **`iOS`**, **`Android`**, and the **`Web`** do not have window control buttons. On some **`Linux`** environments these values have no effect.
InternalWindowStateStores internal [`Window`] state that isn’t directly accessible.
MonitorSelectionReferences a screen monitor. Used when centering a [`Window`] on a monitor.
PresentModePresentation mode for a [`Window`]. The presentation mode specifies when a frame is presented to the window. The [`Fifo`]...
ScreenEdgeThe edges of a screen. Corresponds to [`winit::platform::ios::ScreenEdge`]. # Platform-specific - Only used on iOS. [`winit::platform::ios::ScreenEdge`]...
VideoModeSelectionReferences an exclusive fullscreen video mode. Used when setting [`WindowMode::Fullscreen`] on a window.
WindowLevelSpecifies where a [`Window`] should appear relative to other overlapping windows (on top or under) . Levels are groups of windows with respect to their z-position. The relative ordering between windows in different window levels is fixed. The z-order of windows within the same window level may change dynamically on user interaction. ## Platform-specific - **iOS / Android / Web / Wayland:** Unsupported.
WindowModeDefines the way a [`Window`] is displayed.
WindowPositionDefines where a [`Window`] should be placed on the screen.
WindowRefReference to a [`Window`], whether it be a direct link to a specific entity or a more vague defaulting choice.
WindowResizeConstraintsThe size limits on a [`Window`]. These values are measured in logical pixels (see [`WindowResolution`...
WindowThemeThe [`Window`] theme variant to use.

Values

NameType
ExitSystemsReflectSystemSet

Window

Window

Description

The defining [Component] for window entities, storing information about how it should appear and behave.

Each window corresponds to an entity, and is uniquely identified by the value of their [Entity]. When the [Window] component is added to an entity, a new window will be opened. When it is removed or the entity is despawned, the window will close.

The primary window entity (and the corresponding window) is spawned by default by WindowPlugin and is marked with the [PrimaryWindow] component.

This component is synchronized with winit through bevy_winit: it will reflect the current state of the window and can be modified to change this state.

Example

Because this component is synchronized with winit, it can be used to perform OS-integrated windowing operations. For example, here’s a simple system to change the window mode:

# use bevy_ecs::query::With;
# use bevy_ecs::system::Query;
# use bevy_window::{WindowMode, PrimaryWindow, Window, MonitorSelection, VideoModeSelection};
fn change_window_mode(mut windows: Query<&mut Window, With<PrimaryWindow>>) {
    // Query returns one window typically.
    for mut window in windows.iter_mut() {
        window.mode =
            WindowMode::Fullscreen(MonitorSelection::Current, VideoModeSelection::Current);
    }
}

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
scale_factorThe ratio of physical to logical pixels, for example `2` on a high density screen.
physical_widthThe width of the window in physical pixels.
widthThe width of the window in logical pixels.
primary_entityThe entity of the primary window, or nil if there is none.
primaryThe primary window, or nil if there is none.
set_cursor_positionMoves the cursor to the position in logical pixels, or hides it outside the window when given nil.
physical_heightThe height of the window in physical pixels.
sizeThe size of the window in logical pixels.
heightThe height of the window in logical pixels.
cursor_positionThe position of the cursor in logical pixels from the top left, or nil if the cursor is outside the ...
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

scale_factor

The ratio of physical to logical pixels, for example 2 on a high density screen.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

physical_width

The width of the window in physical pixels.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

width

The width of the window in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

primary_entity

The entity of the primary window, or nil if there is none.

Arguments

Returns

NameTypeDocumentation
returnOptional<Entity>No Documentation 🚧

primary

The primary window, or nil if there is none.

Arguments

Returns

NameTypeDocumentation
returnOptional<ReflectReference>No Documentation 🚧

set_cursor_position

Moves the cursor to the position in logical pixels, or hides it outside the window when given nil.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧
positionOptional<Vec2>No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

physical_height

The height of the window in physical pixels.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnU32No Documentation 🚧

size

The size of the window in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnVec2No Documentation 🚧

height

The height of the window in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

cursor_position

The position of the cursor in logical pixels from the top left, or nil if the cursor is outside the window.

Arguments

NameTypeDocumentation
_selfWindowNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Vec2>No Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Window>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowThe constructed value.

WindowResolution

WindowResolution

  • physical_width:U32
  • physical_height:U32
  • scale_factor_override:Optional<F32>
  • scale_factor:F32

Description

Controls the size of a [Window]

Physical, logical and requested sizes

There are three sizes associated with a window:

  • the physical size, which represents the actual height and width in physical pixels the window occupies on the monitor,
  • the logical size, which represents the size that should be used to scale elements inside the window, measured in logical pixels,
  • the requested size, measured in logical pixels, which is the value submitted to the API when creating the window, or requesting that it be resized.

Scale factor

The reason logical size and physical size are separated and can be different is to account for the cases where:

  • several monitors have different pixel densities,
  • the user has set up a pixel density preference in its operating system,
  • the Bevy App has specified a specific scale factor between both.

The factor between physical size and logical size can be retrieved with [WindowResolution::scale_factor].

For the first two cases, a scale factor is set automatically by the operating system through the window backend. You can get it with [WindowResolution::base_scale_factor].

For the third case, you can override this automatic scale factor with [WindowResolution::set_scale_factor_override].

Requested and obtained sizes

The logical size should be equal to the requested size after creating/resizing, when possible. The reason the requested size and logical size might be different is because the corresponding physical size might exceed limits (either the size limits of the monitor, or limits defined in [WindowResizeConstraints]).

Note: The requested size is not kept in memory, for example requesting a size too big for the screen, making the logical size different from the requested size, and then setting a scale factor that makes the previous requested size within the limits of the screen will not get back that previous requested size.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
scale_factorThe ratio of physical to logical pixels.
widthThe width in logical pixels.
heightThe height in logical pixels.
setSets the size in logical pixels.
newCreates a resolution from a size in physical pixels. ```multi-lang-example,lua local WindowResolution = import_namespace(“window”).WindowResolution local resolution = WindowResolution.new(800, 600) assert(resolution:width() == 800) ``` ```multi-lang-example,rune let WindowResolution = import_...

scale_factor

The ratio of physical to logical pixels.

Arguments

NameTypeDocumentation
_selfWindowResolutionNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

width

The width in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowResolutionNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

height

The height in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowResolutionNo Documentation 🚧

Returns

NameTypeDocumentation
returnF32No Documentation 🚧

set

Sets the size in logical pixels.

Arguments

NameTypeDocumentation
_selfWindowResolutionNo Documentation 🚧
widthF32No Documentation 🚧
heightF32No Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

new

Creates a resolution from a size in physical pixels.

local WindowResolution = import_namespace("window").WindowResolution
local resolution = WindowResolution.new(800, 600)
assert(resolution:width() == 800)
let WindowResolution = import_namespace("window").WindowResolution;
let resolution = WindowResolution.new(800, 600);
assert!(resolution.width() == 800.0);

Arguments

NameTypeDocumentation
physical_widthU32No Documentation 🚧
physical_heightU32No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowResolutionNo Documentation 🚧

VideoMode

VideoMode

  • physical_size:UVec2
  • bit_depth:U16
  • refresh_rate_millihertz:U32

Description

Represents a video mode that a monitor supports

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<VideoMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVideoModeThe constructed value.

CompositeAlphaMode

Auto

Opaque

PreMultiplied

PostMultiplied

Inherit

Description

Specifies how the alpha channel of the textures should be handled during compositing, for a [Window].

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Auto.newNo Documentation 🚧
Inherit.newNo Documentation 🚧
Opaque.newNo Documentation 🚧
PostMultiplied.newNo Documentation 🚧
PreMultiplied.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<CompositeAlphaMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCompositeAlphaModeThe constructed value.

Auto.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompositeAlphaMode::Auto>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompositeAlphaModeNo Documentation 🚧

Inherit.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompositeAlphaMode::Inherit>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompositeAlphaModeNo Documentation 🚧

Opaque.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompositeAlphaMode::Opaque>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompositeAlphaModeNo Documentation 🚧

PostMultiplied.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompositeAlphaMode::PostMultiplied>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompositeAlphaModeNo Documentation 🚧

PreMultiplied.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<CompositeAlphaMode::PreMultiplied>No Documentation 🚧

Returns

NameTypeDocumentation
returnCompositeAlphaModeNo Documentation 🚧

EnabledButtons

EnabledButtons

Description

Specifies which [Window] control buttons should be enabled.

Platform-specific

iOS, Android, and the Web do not have window control buttons.

On some Linux environments these values have no effect.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<EnabledButtons>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceEnabledButtonsThe constructed value.

InternalWindowState

InternalWindowState

  • minimize_request:Optional<Bool>
  • maximize_request:Optional<Bool>
  • drag_move_request:Bool
  • drag_resize_request:Optional<CompassOctant>
  • physical_cursor_position:Optional<DVec2>

Description

Stores internal [Window] state that isn’t directly accessible.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<InternalWindowState>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceInternalWindowStateThe constructed value.

MonitorSelection

Current

Primary

Index

  1. Usize

Entity

  1. Entity

Description

References a screen monitor.

Used when centering a [Window] on a monitor.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Current.newNo Documentation 🚧
Entity.newNo Documentation 🚧
Index.newNo Documentation 🚧
Primary.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<MonitorSelection>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceMonitorSelectionThe constructed value.

Current.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MonitorSelection::Current>No Documentation 🚧

Returns

NameTypeDocumentation
returnMonitorSelectionNo Documentation 🚧

Entity.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MonitorSelection::Entity>No Documentation 🚧

Returns

NameTypeDocumentation
returnMonitorSelectionNo Documentation 🚧

Index.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MonitorSelection::Index>No Documentation 🚧

Returns

NameTypeDocumentation
returnMonitorSelectionNo Documentation 🚧

Primary.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<MonitorSelection::Primary>No Documentation 🚧

Returns

NameTypeDocumentation
returnMonitorSelectionNo Documentation 🚧

PresentMode

AutoVsync

AutoNoVsync

Fifo

FifoRelaxed

Immediate

Mailbox

Description

Presentation mode for a [Window].

The presentation mode specifies when a frame is presented to the window. The Fifo option corresponds to a traditional VSync, where the framerate is capped by the display refresh rate. Both Immediate and Mailbox are low-latency and are not capped by the refresh rate, but may not be available on all platforms. Tearing may be observed with Immediate mode, but will not be observed with Mailbox or Fifo.

AutoVsync or AutoNoVsync will gracefully fallback to Fifo when unavailable.

Immediate or Mailbox will panic if not supported by the platform.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AutoNoVsync.newNo Documentation 🚧
AutoVsync.newNo Documentation 🚧
Fifo.newNo Documentation 🚧
FifoRelaxed.newNo Documentation 🚧
Immediate.newNo Documentation 🚧
Mailbox.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<PresentMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referencePresentModeThe constructed value.

AutoNoVsync.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::AutoNoVsync>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

AutoVsync.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::AutoVsync>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

Fifo.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::Fifo>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

FifoRelaxed.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::FifoRelaxed>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

Immediate.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::Immediate>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

Mailbox.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<PresentMode::Mailbox>No Documentation 🚧

Returns

NameTypeDocumentation
returnPresentModeNo Documentation 🚧

ScreenEdge

None

Top

Left

Bottom

Right

All

Description

The edges of a screen. Corresponds to winit::platform::ios::ScreenEdge.

Platform-specific

  • Only used on iOS.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
All.newNo Documentation 🚧
Bottom.newNo Documentation 🚧
Left.newNo Documentation 🚧
None.newNo Documentation 🚧
Right.newNo Documentation 🚧
Top.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScreenEdge>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScreenEdgeThe constructed value.

All.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::All>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

Bottom.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::Bottom>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

Left.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::Left>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

None.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::None>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

Right.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::Right>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

Top.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<ScreenEdge::Top>No Documentation 🚧

Returns

NameTypeDocumentation
returnScreenEdgeNo Documentation 🚧

VideoModeSelection

Current

Specific

  1. VideoMode

Description

References an exclusive fullscreen video mode.

Used when setting [WindowMode::Fullscreen] on a window.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Current.newNo Documentation 🚧
Specific.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<VideoModeSelection>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceVideoModeSelectionThe constructed value.

Current.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<VideoModeSelection::Current>No Documentation 🚧

Returns

NameTypeDocumentation
returnVideoModeSelectionNo Documentation 🚧

Specific.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<VideoModeSelection::Specific>No Documentation 🚧

Returns

NameTypeDocumentation
returnVideoModeSelectionNo Documentation 🚧

WindowLevel

AlwaysOnBottom

Normal

AlwaysOnTop

Description

Specifies where a [Window] should appear relative to other overlapping windows (on top or under) .

Levels are groups of windows with respect to their z-position.

The relative ordering between windows in different window levels is fixed. The z-order of windows within the same window level may change dynamically on user interaction.

Platform-specific

  • iOS / Android / Web / Wayland: Unsupported.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
AlwaysOnBottom.newNo Documentation 🚧
AlwaysOnTop.newNo Documentation 🚧
Normal.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowLevel>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowLevelThe constructed value.

AlwaysOnBottom.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowLevel::AlwaysOnBottom>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowLevelNo Documentation 🚧

AlwaysOnTop.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowLevel::AlwaysOnTop>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowLevelNo Documentation 🚧

Normal.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowLevel::Normal>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowLevelNo Documentation 🚧

WindowMode

Windowed

BorderlessFullscreen

  1. MonitorSelection

Fullscreen

  1. MonitorSelection
  2. VideoModeSelection

Description

Defines the way a [Window] is displayed.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
BorderlessFullscreen.newNo Documentation 🚧
Fullscreen.newNo Documentation 🚧
Windowed.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowMode>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowModeThe constructed value.

BorderlessFullscreen.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowMode::BorderlessFullscreen>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowModeNo Documentation 🚧

Fullscreen.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowMode::Fullscreen>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowModeNo Documentation 🚧

Windowed.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowMode::Windowed>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowModeNo Documentation 🚧

WindowPosition

Automatic

Centered

  1. MonitorSelection

At

  1. IVec2

Description

Defines where a [Window] should be placed on the screen.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
At.newNo Documentation 🚧
Automatic.newNo Documentation 🚧
Centered.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowPosition>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowPositionThe constructed value.

At.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowPosition::At>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowPositionNo Documentation 🚧

Automatic.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowPosition::Automatic>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowPositionNo Documentation 🚧

Centered.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowPosition::Centered>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowPositionNo Documentation 🚧

WindowRef

Primary

Entity

  1. Entity

Description

Reference to a [Window], whether it be a direct link to a specific entity or a more vague defaulting choice.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Entity.newNo Documentation 🚧
Primary.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowRef>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowRefThe constructed value.

Entity.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowRef::Entity>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowRefNo Documentation 🚧

Primary.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowRef::Primary>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowRefNo Documentation 🚧

WindowResizeConstraints

WindowResizeConstraints

Description

The size limits on a [Window].

These values are measured in logical pixels (see [WindowResolution]), so the user’s scale factor does affect the size limits on the window.

Please note that if the window is resizable, then when the window is maximized it may have a size outside of these limits. The functionality required to disable maximizing is not yet exposed by winit.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowResizeConstraints>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowResizeConstraintsThe constructed value.

WindowTheme

Light

Dark

Description

The [Window] theme variant to use.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...
Dark.newNo Documentation 🚧
Light.newNo Documentation 🚧

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<WindowTheme>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceWindowThemeThe constructed value.

Dark.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowTheme::Dark>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowThemeNo Documentation 🚧

Light.new

No Documentation 🚧

Arguments

NameTypeDocumentation
variantEnumVariantRefNo Documentation 🚧
payloadFields<WindowTheme::Light>No Documentation 🚧

Returns

NameTypeDocumentation
returnWindowThemeNo Documentation 🚧

window.CursorSystems

The types and functions in the window.CursorSystems namespace, as returned by import_namespace("window.CursorSystems").

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

Values

NameType
UpdateReflectSystemSet

root

The types without a crate, such as primitives.

Available Types

All registered reflect-able types which can be constructed and directly manipulated by scripts.

TypeSummary
WorldThe ECS world containing all Components, Resources and Systems. Main point of interaction with a Bev...
BoolA boolean value
CharAn 8-bit character
DynamicFunctionMutA stateful and callable dynamic function
F32A 32-bit floating point number
F64A 64-bit floating point number
FunctionCallContextFunction call context, if accepted by a function, means the function can access the world in arbitra...
I128A signed 128-bit integer
I16A signed 16-bit integer
I32A signed 32-bit integer
I64A signed 64-bit integer
I8A signed 8-bit integer
IsizeA signed pointer-sized integer
ReflectReferenceA reference to a reflectable type
ScriptValueA value representing the union of all representable values
StaticTypeRefA type itself, used to reach its static members, i.e. `Vec3` in `Vec3.new{}`. Functions on it are sh...
StringA heap allocated string
U128An unsigned 128-bit integer
U16An unsigned 16-bit integer
U32An unsigned 32-bit integer
U64An unsigned 64-bit integer
U8An unsigned 8-bit integer
UsizeAn unsigned pointer-sized integer
DynamicFunctionA callable dynamic function
OsStringA heap allocated OS string
PathBufA heap allocated file path
StrA string slice

World

Opaque Type. 🔒

Description

The ECS world containing all Components, Resources and Systems. Main point of interaction with a Bevy App.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
trigger_eventTriggers an observer-style event: either a Rust event type with `#[reflect(Event)]`, or an event registered with `register_new_event`. Observers run immediately, and the commands they queue are applied before this function returns.
add_observerAdds an observer which runs the callback `callback` of the calling script whenever an event of the g...
has_componentChecks if the given entity has the given component.
gamepadsThe entities of the connected gamepads.
has_resourceChecks if the world has the given resource.
get_system_set_by_nameRetrieves a system set by its full name, i.e. `transform.TransformSystems.Propagate` for a set of th...
get_parentRetrieves the parent of the given entity.
queryCreates a new `ScriptQueryBuilder` which can be used to query the ECS. Returns: * `query`: The new query builder.
get_type_by_nameReturns either a `ScriptComponentRegistration`, `ScriptResourceRegistration` or `ScriptBundleRegistration`...
insert_componentInserts the given component value into the provided entity
insert_childrenInserts the given children entities into the provided parent entity.
spawn_bundleSpawns a new entity with the given bundle value and returns it.
get_schedule_by_nameRetrieves the schedule with the given name, Also ensures the schedule is initialized before returnin...
push_childrenPushes the given children entities into the provided parent entity.
virtual_timeThe clock which can be paused and slowed down, it is the one games usually move objects with.
add_systemAdds the given system to the world.
get_enum_variantRetrieves the variant of an enum by name. This is the same as accessing `MyEnum.Variant`, but works...
add_default_componentAdds the given resource to the world.
asset_pathThe path the asset was loaded from, or nil if the handle is invalid or the asset was not loaded from...
get_resourceRetrieves the resource with the given registration.
set_next_stateSets the state to change to in the next state transition, for the type of the given state value. Er...
write_messageWrites a buffered message. The message type must be registered and have `#[reflect(Message)]`.
find_entity_by_nameThe first entity with the given [`Name`](bevy_ecs::name::Name), or nil if there is none.
despawn_descendantsDespawn the descendants of the given entity.
insert_bundleInserts the given bundle value into the provided entity, all of its components at once. The bundle ...
get_stateThe current value of the state of the given type, or nil if the app has no such state. The state ty...
real_timeThe clock of the real world, which always advances at the system’s pace.
load_assetStarts loading an asset of the given type from a path, returning a handle to it right away.
fixed_timeThe clock of the fixed update step, which advances in steps of the fixed timestep.
remove_componentRemoves the given component from the entity.
get_componentTries to retrieve the given component type on an entity.
add_assetAdds a value as a new asset of its type, returning a strong handle to it.
load_stateThe loading state of the asset: `“NotLoaded”`, `“Loading”`, `“Loaded”` or `“Failed”`.
exitQuits the program.
register_new_componentRegisters a new component type with the world. The component will behave like any other native comp...
register_new_system_setRegisters a new system set, which script systems can be put in and ordered against. The set is remo...
is_loadedWhether the asset and all of its dependencies are loaded.
despawnDespawns the given entity.
has_entityChecks if the given entity exists.
has_assetChecks if can get asset handle
get_childrenRetrieves the children of the given entity.
timeThe default clock: in Update it advances by the frame time, in FixedUpdate by the fixed timestep.
register_new_eventRegisters a new script event. Script events carry an arbitrary payload, and can be observed with `add_observer` and triggered with `trigger_...
despawn_recursiveDespawns the entity and all its descendants.
get_assetRetrieves an asset by its handle and asset type registration.
spawnSpawns a new entity and returns it
remove_resourceRemoves the given resource from the world.

trigger_event

Triggers an observer-style event: either a Rust event type with #[reflect(Event)], or an event registered with register_new_event.

Observers run immediately, and the commands they queue are applied before this function returns.

Arguments

NameTypeDocumentation
eventScriptTypeRegistrationScriptEventRegistration
valueOptional<ScriptValue>The event value, e.g. built with construct, for Rust events. Any value (or nothing) for script events, which is passed to the observers.

Returns

NameTypeDocumentation
result()Nothing if the event was triggered successfully.

add_observer

Adds an observer which runs the callback callback of the calling script whenever an event of the given type is triggered.

The callback is a normal script callback: either a function registered with register_callback, or a top level function with that name. It receives a copy of the event (or the payload, for script events), and is run by the same machinery as other callbacks: right after the operation which triggered the event, unless the script’s context is busy running another callback (e.g. the one that triggered the event), in which case it runs as soon as that callback finishes. Observers never re-enter a running script. The order in which the observers of an event run is unspecified. Removed component data is no longer available inside the callback. Errors of the callback are reported like those of other callbacks.

The event type must have #[reflect(Event)]. The lifecycle events (AddEvent, InsertEvent, DiscardEvent, RemoveEvent, DespawnEvent, imported with import_namespace("bevy_ecs")) are supported out of the box, and run for the given components.

Arguments

NameTypeDocumentation
eventScriptTypeRegistrationScriptEventRegistration
callbackStringThe label of the callback to run, receives the event.
componentsOptional<Vec<ScriptComponentRegistration>>The components the observer is interested in, for component lifecycle events. Ignored for script events.
entitiesOptional<Vec<Entity>>If given, the observer only runs for these entities. Ignored for script events.

Returns

NameTypeDocumentation
observerEntityThe observer entity, despawn it to remove the observer.

has_component

Checks if the given entity has the given component.

Arguments

NameTypeDocumentation
entityEntityThe entity to check.
registrationScriptComponentRegistrationThe component to check for.

Returns

NameTypeDocumentation
has_componentBoolWhether the entity has the component.

gamepads

The entities of the connected gamepads.

Arguments

Returns

NameTypeDocumentation
returnVec<Entity>No Documentation 🚧

has_resource

Checks if the world has the given resource.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe registration of the resource to check for.

Returns

NameTypeDocumentation
has_resourceBoolWhether the world has the resource.

get_system_set_by_name

Retrieves a system set by its full name, i.e. transform.TransformSystems.Propagate for a set of the game, or script.my_game.ai for a set registered by a script.

The sets of the game are also members of their namespace, i.e. import_namespace("transform.TransformSystems").Propagate.

Arguments

NameTypeDocumentation
nameStringThe full name of the system set.

Returns

NameTypeDocumentation
setOptional<ReflectSystemSet>The system set with the given name, if it exists.

get_parent

Retrieves the parent of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the parent of.

Returns

NameTypeDocumentation
parentOptional<Entity>The parent of the entity

query

Creates a new ScriptQueryBuilder which can be used to query the ECS.

Returns:

  • query: The new query builder.

Arguments

Returns

NameTypeDocumentation
returnScriptQueryBuilderNo Documentation 🚧

get_type_by_name

Returns either a ScriptComponentRegistration, ScriptResourceRegistration or ScriptBundleRegistration depending on the type of the type requested. If the type is none of these returns a ScriptTypeRegistration.

Arguments

NameTypeDocumentation
type_nameStringThe full path of the type to retrieve, i.e. bevy_transform::components::transform::Transform or script.my_game.Enemy.

Returns

NameTypeDocumentation
typeOptional<ScriptTypeRegistrationScriptComponentRegistration

insert_component

Inserts the given component value into the provided entity

Arguments

NameTypeDocumentation
entityEntityThe entity to insert the component into.
registrationScriptComponentRegistrationThe component registration of the component to insert.
valueReflectReferenceThe value of the component to insert. Can be constructed using construct

Returns

NameTypeDocumentation
result()Nothing if the component was inserted successfully.

insert_children

Inserts the given children entities into the provided parent entity.

Arguments

NameTypeDocumentation
entityEntityThe parent entity to receive children
indexUsizeThe index to insert the children at
childrenVec<Entity>The children entities to insert

Returns

NameTypeDocumentation
result()Nothing if the children were inserted successfully.

spawn_bundle

Spawns a new entity with the given bundle value and returns it.

Arguments

NameTypeDocumentation
registrationScriptBundleRegistrationThe bundle registration of the bundle to insert.
valueReflectReferenceThe value of the bundle to insert.

Returns

NameTypeDocumentation
entityEntityThe newly spawned entity

get_schedule_by_name

Retrieves the schedule with the given name, Also ensures the schedule is initialized before returning it.

Schedules in bevy are “containers” for systems, each schedule runs separately and contains different systems.

By default among others bevy contains the following schedules:

  • Update: Runs every frame.
  • PostUpdate: Runs after the Update schedule.
  • FixedUpdate: Runs at a fixed rate.

Arguments

NameTypeDocumentation
nameStringThe name of the schedule to retrieve.

Returns

NameTypeDocumentation
scheduleOptional<ReflectSchedule>The schedule with the given name, if it exists

push_children

Pushes the given children entities into the provided parent entity.

Arguments

NameTypeDocumentation
entityEntityThe parent entity to receive children
childrenVec<Entity>The children entities to push

Returns

NameTypeDocumentation
result()Nothing if the children were pushed successfully.

virtual_time

The clock which can be paused and slowed down, it is the one games usually move objects with.

Arguments

Returns

NameTypeDocumentation
returnReflectReferenceNo Documentation 🚧

add_system

Adds the given system to the world.

Arguments

NameTypeDocumentation
scheduleReflectScheduleThe schedule to add the system to.
builderScriptSystemBuilderThe system builder specifying the system and its dependencies.

Returns

NameTypeDocumentation
systemReflectSystemThe system that was added.

get_enum_variant

Retrieves the variant of an enum by name.

This is the same as accessing MyEnum.Variant, but works for variants which share a name with a function.

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationScriptComponentRegistration
variant_nameStringThe name of the variant.

Returns

NameTypeDocumentation
variantOptional<EnumVariantRef>The variant, if the type is an enum with such a variant.

add_default_component

Adds the given resource to the world.

Arguments

NameTypeDocumentation
entityEntityNo Documentation 🚧
registrationScriptComponentRegistrationThe resource to add.

Returns

NameTypeDocumentation
result()Nothing if the resource was added successfully.

asset_path

The path the asset was loaded from, or nil if the handle is invalid or the asset was not loaded from a path.

Arguments

NameTypeDocumentation
handleReflectReferenceThe handle to the asset.

Returns

NameTypeDocumentation
pathOptional<String>The asset path, if known.

get_resource

Retrieves the resource with the given registration.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe registration of the resource to retrieve.

Returns

NameTypeDocumentation
resourceOptional<ReflectReference>The resource, if it exists.

set_next_state

Sets the state to change to in the next state transition, for the type of the given state value.

Errors if the value is not of a state type that the app has.

Arguments

NameTypeDocumentation
valueReflectReferenceNo Documentation 🚧

Returns

NameTypeDocumentation
return()No Documentation 🚧

write_message

Writes a buffered message. The message type must be registered and have #[reflect(Message)].

Arguments

NameTypeDocumentation
registrationScriptTypeRegistrationThe type of the message.
messageReflectReferenceThe message value, e.g. built with construct.

Returns

NameTypeDocumentation
result()Nothing if the message was written successfully.

find_entity_by_name

The first entity with the given Name, or nil if there is none.

Arguments

NameTypeDocumentation
nameStringNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<Entity>No Documentation 🚧

despawn_descendants

Despawn the descendants of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn the descendants of.

Returns

NameTypeDocumentation
result()Nothing if the descendants were despawned successfully.

insert_bundle

Inserts the given bundle value into the provided entity, all of its components at once.

The bundle type must be registered in rust with #[reflect(Bundle)].

Arguments

NameTypeDocumentation
entityEntityThe entity to insert the bundle into.
registrationScriptBundleRegistrationThe bundle registration of the bundle to insert.
valueReflectReferenceThe value of the bundle to insert. Can be constructed like any other value, i.e. using construct or the type’s new function.

Returns

NameTypeDocumentation
result()Nothing if the bundle was inserted successfully.

get_state

The current value of the state of the given type, or nil if the app has no such state.

The state type is passed as its registration, see world.get_type_by_name.

Arguments

NameTypeDocumentation
state_typeScriptTypeRegistrationNo Documentation 🚧

Returns

NameTypeDocumentation
returnOptional<ReflectReference>No Documentation 🚧

real_time

The clock of the real world, which always advances at the system’s pace.

Arguments

Returns

NameTypeDocumentation
returnReflectReferenceNo Documentation 🚧

load_asset

Starts loading an asset of the given type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
pathStringThe asset path, relative to the assets folder.
asset_typeScriptTypeRegistrationThe type of the asset, i.e. bevy_mod_scripting_asset::script_asset::ScriptAsset.

Returns

NameTypeDocumentation
handleReflectReferenceA handle to the asset, which is loaded in the background.

fixed_time

The clock of the fixed update step, which advances in steps of the fixed timestep.

Arguments

Returns

NameTypeDocumentation
returnReflectReferenceNo Documentation 🚧

remove_component

Removes the given component from the entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to remove the component from.
registrationScriptComponentRegistrationThe component to remove.

Returns

NameTypeDocumentation
result()Nothing if the component was removed successfully or didn’t exist in the first place.

get_component

Tries to retrieve the given component type on an entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the component from.
registrationScriptComponentRegistrationThe component to retrieve.

Returns

NameTypeDocumentation
componentOptional<ReflectReference>The component on the entity, if it exists.

add_asset

Adds a value as a new asset of its type, returning a strong handle to it.

Arguments

NameTypeDocumentation
valueReflectReferenceThe asset value, of a type registered for asset reflection.

Returns

NameTypeDocumentation
handleReflectReferenceA handle to the new asset.

load_state

The loading state of the asset: "NotLoaded", "Loading", "Loaded" or "Failed".

Arguments

NameTypeDocumentation
handleReflectReferenceThe handle to the asset.

Returns

NameTypeDocumentation
stateStringThe name of the loading state.

exit

Quits the program.

Arguments

Returns

NameTypeDocumentation
result()Nothing if the program was exited successfully.

register_new_component

Registers a new component type with the world.

The component will behave like any other native component for all intents and purposes. The type that will be instantiated to back this component will be DynamicComponent which contains just one field:

  • data

This field can be set to any value and modified freely.

Arguments

NameTypeDocumentation
namespaceStringThe script namespace to register the component in, it must start with script., i.e. script.my_game. Scripts cannot add to other namespaces.
nameStringThe name of the component type, unique within the namespace. The component can later be found as import_namespace(namespace).name.
allow_existingOptional<Bool>If true, returns the registration of the already registered component with this name instead of failing. Defaults to false.

Returns

NameTypeDocumentation
registrationScriptComponentRegistrationThe registration of the new component type if successful.

register_new_system_set

Registers a new system set, which script systems can be put in and ordered against.

The set is removed from its namespace when the script unloads, registering it again (i.e. after a reload) gives the same set.

Arguments

NameTypeDocumentation
namespaceStringThe script namespace to register the set in, it must start with script., i.e. script.my_game.
nameStringThe name of the set, unique within the namespace. The set can later be found as import_namespace(namespace).name.
allow_existingOptional<Bool>If true, returns the already registered set with this name instead of failing. Defaults to false.

Returns

NameTypeDocumentation
setReflectSystemSetThe new system set.

is_loaded

Whether the asset and all of its dependencies are loaded.

Arguments

NameTypeDocumentation
handleReflectReferenceThe handle to the asset.

Returns

NameTypeDocumentation
loadedBoolWhether the asset and its dependencies are loaded.

despawn

Despawns the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn.

Returns

NameTypeDocumentation
return()No Documentation 🚧

has_entity

Checks if the given entity exists.

Arguments

NameTypeDocumentation
eEntityNo Documentation 🚧

Returns

NameTypeDocumentation
has_entityBoolWhether the entity exists.

has_asset

Checks if can get asset handle

Arguments

NameTypeDocumentation
handle_referenceReflectReferenceNo Documentation 🚧

Returns

NameTypeDocumentation
returnBoolNo Documentation 🚧

get_children

Retrieves the children of the given entity.

Arguments

NameTypeDocumentation
entityEntityThe entity to retrieve the children of.

Returns

NameTypeDocumentation
childrenVec<Entity>The children of the entity.

time

The default clock: in Update it advances by the frame time, in FixedUpdate by the fixed timestep.

Arguments

Returns

NameTypeDocumentation
returnReflectReferenceNo Documentation 🚧

register_new_event

Registers a new script event.

Script events carry an arbitrary payload, and can be observed with add_observer and triggered with trigger_event.

Arguments

NameTypeDocumentation
namespaceStringThe script namespace to register the event in, it must start with script., i.e. script.my_game.
nameStringThe name of the event, unique within the namespace.
allow_existingOptional<Bool>If true, returns the already registered event with this name instead of failing. Defaults to false.

Returns

NameTypeDocumentation
registrationScriptEventRegistrationThe handle of the new event.

despawn_recursive

Despawns the entity and all its descendants.

Arguments

NameTypeDocumentation
entityEntityThe entity to despawn recursively.

Returns

NameTypeDocumentation
result()Nothing if the entity and its descendants were despawned successfully.

get_asset

Retrieves an asset by its handle and asset type registration.

Arguments

NameTypeDocumentation
handle_referenceReflectReferenceThe handle to the asset (as a reflect reference).
registrationScriptTypeRegistrationThe type registration of the asset type.

Returns

NameTypeDocumentation
assetOptional<ReflectReference>The asset reference, if the asset is loaded.

spawn

Spawns a new entity and returns it

Arguments

Returns

NameTypeDocumentation
entityEntityThe newly spawned entity

remove_resource

Removes the given resource from the world.

Arguments

NameTypeDocumentation
registrationScriptResourceRegistrationThe resource to remove.

Returns

NameTypeDocumentation
result()Nothing if the resource was removed successfully or didn’t exist in the first place.

Bool

Opaque Type. 🔒

Description

A boolean value

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Bool>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceBoolThe constructed value.

Char

Opaque Type. 🔒

Description

An 8-bit character

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Char>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceCharThe constructed value.

DynamicFunctionMut

Opaque Type. 🔒

Description

A stateful and callable dynamic function

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<DynamicFunctionMut>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceDynamicFunctionMutThe constructed value.

F32

Opaque Type. 🔒

Description

A 32-bit floating point number

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<F32>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceF32The constructed value.

F64

Opaque Type. 🔒

Description

A 64-bit floating point number

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<F64>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceF64The constructed value.

FunctionCallContext

Opaque Type. 🔒

Description

Function call context, if accepted by a function, means the function can access the world in arbitrary ways.

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<FunctionCallContext>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceFunctionCallContextThe constructed value.

I128

Opaque Type. 🔒

Description

A signed 128-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<I128>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceI128The constructed value.

I16

Opaque Type. 🔒

Description

A signed 16-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<I16>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceI16The constructed value.

I32

Opaque Type. 🔒

Description

A signed 32-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<I32>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceI32The constructed value.

I64

Opaque Type. 🔒

Description

A signed 64-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<I64>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceI64The constructed value.

I8

Opaque Type. 🔒

Description

A signed 8-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<I8>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceI8The constructed value.

Isize

Opaque Type. 🔒

Description

A signed pointer-sized integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Isize>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceIsizeThe constructed value.

ReflectReference

Opaque Type. 🔒

Description

A reference to a reflectable type

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
variantIf this is an enum, returns a reference to the variant it is currently in. This can be compared to `MyEnum.Variant`...
map_getGets and clones the value under the specified key if the underlying type is a map type.
lenRetrieves the length of the reference, if the reference is an appropriate container type.
cloneCreates an independent copy of the value, so that changing one doesn’t change the other.
eqWhether two values are equal, compared through reflection. This is what `==` uses for types which d...
insertInserts the value into the reference at the specified index, if the reference is an appropriate cont...
displayDisplays this reference and its contents if possible. This is useful for debugging and logging.
functionsLists the functions available on the reference.
iterIterates over the reference, if the reference is an appropriate container type. Returns an “next” i...
variant_nameIf this type is an enum, will return the name of the variant it represents on the type.
pushPushes the value into the reference, if the reference is an appropriate container type.
clearClears the container, if the reference is an appropriate container type.
debugDisplays a debug representation of this reference. This is useful for debugging and logging.
removeRemoves the value at the specified key from the reference, if the reference is an appropriate contai...
popPops the value from the reference, if the reference is an appropriate container type.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

variant

If this is an enum, returns a reference to the variant it is currently in.

This can be compared to MyEnum.Variant to check which variant a value is in.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to get the variant of.

Returns

NameTypeDocumentation
variantOptional<EnumVariantRef>The variant, if the reference is an enum.

map_get

Gets and clones the value under the specified key if the underlying type is a map type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to index into.
keyScriptValueThe key to index with.

Returns

NameTypeDocumentation
valueOptional<ScriptValue>The value at the key, if the reference is a map.

len

Retrieves the length of the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to get the length of.

Returns

NameTypeDocumentation
lenOptional<Usize>The length of the reference, if the reference is a container.

clone

Creates an independent copy of the value, so that changing one doesn’t change the other.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe value to copy.

Returns

NameTypeDocumentation
copyScriptValueThe copy.

eq

Whether two values are equal, compared through reflection.

This is what == uses for types which don’t define their own equality. Values of different types, and values which can’t be compared, are not equal. An enum value is equal to an enum variant, i.e. MyEnum.Variant, if it is in that variant.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe value to compare.
otherScriptValueThe value to compare with.

Returns

NameTypeDocumentation
equalBoolWhether the values are equal.

insert

Inserts the value into the reference at the specified index, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to insert the value into.
keyScriptValueThe index to insert the value at.
valueScriptValueThe value to insert.

Returns

NameTypeDocumentation
result()Nothing if the value was inserted successfully.

display

Displays this reference and its contents if possible.

This is useful for debugging and logging.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to display.

Returns

NameTypeDocumentation
displayStringThe display string.

functions

Lists the functions available on the reference.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to list the functions of.

Returns

NameTypeDocumentation
functionsVec<FunctionInfo>The functions available on the reference.

iter

Iterates over the reference, if the reference is an appropriate container type.

Returns an “next” iterator function.

The iterator function should be called until it returns nil to signal the end of the iteration.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to iterate over.

Returns

NameTypeDocumentation
iterDynamicFunctionMutThe iterator function.

variant_name

If this type is an enum, will return the name of the variant it represents on the type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to get the variant name of.

Returns

NameTypeDocumentation
variant_nameOptional<String>The name of the variant, if the reference is an enum.

push

Pushes the value into the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to push the value into.
valueScriptValueThe value to push.

Returns

NameTypeDocumentation
result()Nothing if the value was pushed successfully.

clear

Clears the container, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to clear.

Returns

NameTypeDocumentation
result()Nothing if the reference was cleared

debug

Displays a debug representation of this reference.

This is useful for debugging and logging.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to display.

Returns

NameTypeDocumentation
displayStringThe display string.

remove

Removes the value at the specified key from the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to remove the value from.
keyScriptValueThe key to remove the value at.

Returns

NameTypeDocumentation
resultScriptValueThe removed value if any

pop

Pops the value from the reference, if the reference is an appropriate container type.

Arguments

NameTypeDocumentation
referenceReflectReferenceThe reference to pop the value from.

Returns

NameTypeDocumentation
valueScriptValueThe value that was popped, if the reference supports popping.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ReflectReference>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectReferenceThe constructed value.

ScriptValue

Opaque Type. 🔒

Description

A value representing the union of all representable values

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<ScriptValue>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceScriptValueThe constructed value.

StaticTypeRef

Opaque Type. 🔒

Description

A type itself, used to reach its static members, i.e. Vec3 in Vec3.new{}. Functions on it are shared by all types

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
add_assetAdds a value of this type as a new asset, returning a strong handle to it.
get_assetThe asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value...
loadStarts loading an asset of this type from a path, returning a handle to it right away.
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

add_asset

Adds a value of this type as a new asset, returning a strong handle to it.

Arguments

NameTypeDocumentation
asset_typeStaticTypeRefThe asset type, filled in automatically.
valueReflectReferenceThe asset value.

Returns

NameTypeDocumentation
handleReflectReferenceA handle to the new asset.

get_asset

The asset a handle points to, or nil if it isn’t loaded or added yet.

Changes to the returned value change the asset.

Arguments

NameTypeDocumentation
asset_typeStaticTypeRefThe asset type, filled in automatically.
handleReflectReferenceThe handle to the asset.

Returns

NameTypeDocumentation
assetOptional<ReflectReference>The asset, or nil.

load

Starts loading an asset of this type from a path, returning a handle to it right away.

Arguments

NameTypeDocumentation
asset_typeStaticTypeRefThe asset type, filled in automatically.
pathStringThe asset path, relative to the assets folder.

Returns

NameTypeDocumentation
handleReflectReferenceA handle to the asset, which is loaded in the background.

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
typeStaticTypeRefThe type to construct.
payloadHashMap<String, ScriptValue>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceReflectReferenceThe constructed value.

String

Opaque Type. 🔒

Description

A heap allocated string

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<String>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceStringThe constructed value.

U128

Opaque Type. 🔒

Description

An unsigned 128-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<U128>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceU128The constructed value.

U16

Opaque Type. 🔒

Description

An unsigned 16-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<U16>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceU16The constructed value.

U32

Opaque Type. 🔒

Description

An unsigned 32-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<U32>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceU32The constructed value.

U64

Opaque Type. 🔒

Description

An unsigned 64-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<U64>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceU64The constructed value.

U8

Opaque Type. 🔒

Description

An unsigned 8-bit integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<U8>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceU8The constructed value.

Usize

Opaque Type. 🔒

Description

An unsigned pointer-sized integer

Associated Functions

For function details and documentation, click on the function link.

FunctionSummary
newConstructs a new instance of the type from a table of its fields. Missing fields are filled in from ...

new

Constructs a new instance of the type from a table of its fields. Missing fields are filled in from the type’s default, then from the defaults of the fields’ types. For enums use the variant key, or construct from a variant directly.

Arguments

NameTypeDocumentation
payloadFields<Usize>The fields of the type, keyed by name or index, or a list of the fields in order.

Returns

NameTypeDocumentation
referenceUsizeThe constructed value.

DynamicFunction

Opaque Type. 🔒

Description

A callable dynamic function

Associated Functions

For function details and documentation, click on the function link.

OsString

Opaque Type. 🔒

Description

A heap allocated OS string

Associated Functions

For function details and documentation, click on the function link.

PathBuf

Opaque Type. 🔒

Description

A heap allocated file path

Associated Functions

For function details and documentation, click on the function link.

Str

Opaque Type. 🔒

Description

A string slice

Associated Functions

For function details and documentation, click on the function link.

Core Callbacks

On top of callbacks which are registered by your application, BMS provides a set of core callbacks which are always available (unless disabled via plugin settings).

The three core callbacks are:

  • on_script_loaded
  • on_script_unloaded
  • on_script_reloaded

For more information on how callbacks generally work see the callbacks section.

on_script_loaded

This will be called right after a script has been loaded or reloaded. This is a good place to initialize your script. You should avoid placing a lot of logic into the global body of your script, and instead put it into this callback. Otherwise errors in the initialization will fail the loading of the script.

print("you can also use this space, but it's not recommended")
function on_script_loaded()
    print("Hello world")
end

on_script_unloaded

This will be called right before a script is unloaded. This is a good place to clean up any resources that your script has allocated. This is called both before a script is removed as well as before a script is reloaded. If you want to preserve the state of your script across reloads, you can return a value from this callback, which will be passed to on_script_reloaded when the script is reloaded.

function on_script_unloaded()
    print("Goodbye world")
    return "house key"
end

on_script_reloaded

Called right after on_script_loaded but only if the script was reloaded. The callback is passed a state argument, this state is exactly what is returned by the script through on_script_unloaded before a reload happens.

mode = 1
function on_script_reloaded(value)
    if value then
        print("I'm back. Thanks for the keys!")
    else
        print('I have not saved any state before unloading')
    end
end

Using on_script_reloaded one can make a script reload preserve its current state.

Asset Operations

BMS provides built-in support for working with Bevy assets from scripts. You can load assets, add new ones, and read or change asset data through the reflection system.

Prerequisites

To use asset operations in your scripts, you need to ensure that:

  1. Your asset type implements Asset and Reflect
  2. The asset type is registered with app.register_asset_reflect::<YourAsset>()
  3. The asset handle type has ReflectHandle type data registered (register_asset_reflect does this)

Functions on asset types

Every asset type has these functions, which are documented with the type’s own handle, i.e. Handle<Image> for Image:

Type.load(path)

Starts loading an asset of this type from a path relative to the assets folder, and returns a handle to it right away. The asset is loaded in the background, see world.is_loaded(handle).

Type.add_asset(value)

Adds a value of this type as a new asset, and returns a strong handle to it.

Type.get_asset(handle)

Returns the asset a handle points to, or nil if it isn’t loaded or added yet. Changes to the returned value change the asset.

local ScriptAsset = import_namespace("bms").ScriptAsset
local handle = ScriptAsset.load("scripts/my_script.lua")
-- later, once `world.is_loaded(handle)` is true
local script = ScriptAsset.get_asset(handle)

Functions on world

The same operations are available on world, taking the asset type as an argument, along with functions for any handle:

  • world.load_asset(path, asset_type): like Type.load
  • world.add_asset(value): like Type.add_asset
  • world.get_asset(handle, asset_type): a reference to the asset
  • world.has_asset(handle): whether the handle is a valid asset handle
  • world.is_loaded(handle): whether the asset and all of its dependencies are loaded
  • world.load_state(handle): "NotLoaded", "Loading", "Loaded" or "Failed"
  • world.asset_path(handle): the path the asset was loaded from, or nil

Examples: See usage examples in the assets/tests/asset_operations and assets/tests/bindings/asset directories.

Developing BMS

This section is for developers who want to contribute to the BMS project. It covers various topics necessary for understanding the project and contributing to it.

Contributing

Please see the code of conduct as well as the contributing guidelines first.

Setup

this crate contains a work in progress xtask setup which in theory should allow you to setup everything you need for local development by running:

cargo xtask init

This command currently supports the following IDE’s

If you’d like to add support for another IDE, please feel free to open a PR!

Writing Bindings

The bevy bindings shipped with BMS are hand written, using the #[script_bindings] macro (see Controlling Script Bindings). They live in crates/bindings/bevy_mod_scripting_bevy_<category>_bindings, one crate per area of functionality (i.e. math, ecs, ui) rather than one per upstream bevy crate.

The aim is a small, well documented scripting surface, which reads naturally from a script and compiles quickly.

Namespaces

Scripts reach types through the namespace of their category, i.e. import_namespace("math").Vec3 (see Namespaces). So each bindings crate:

  • passes namespace = "<category>" to every #[script_bindings] attribute, except on impl World blocks and on functions shared by all types (impl StaticTypeRef), which would otherwise move those BMS types into the category
  • calls set_crate_script_namespaces from its plugin’s finish, with the bevy crates it covers, so their types without bindings land in the same namespace

What to bind

Every reflected type is already usable from scripts without any bindings:

  • fields are read and written through references, i.e. transform.translation.x = 2
  • every type can be constructed with Type.new({...}), see Constructing Arbitrary Types
  • enum variants are available as Type.Variant
  • containers support len, iter, push etc., and every value can be printed

So only bind what scripts can’t already do, or can’t do comfortably:

  • methods with behaviour, i.e. Vec3:normalize() or Transform:look_at(...)
  • constructors for types which are built often (vectors, colors), or whose fields are private (i.e. Name), or whose meaning isn’t obvious from their fields (i.e. Quat.from_rotation_y)
  • operators, by registering functions named add, sub, mul, div, rem, neg, pow, eq or lt. With a number on the left, i.e. 2 * v, add and mul are called with the operands swapped, the others call rsub, rdiv, rrem or rpow on the right operand, which you register where they make sense

Do not write getters or setters for public fields.

Performance

  • Take non primitive arguments as R<T> or M<T>. These are a downcast of the reference the script holds, while V<T> rebuilds the value through reflection. Clone natively if you need ownership.
  • Return a reference with an extended path when returning a part of the receiver; it costs nothing, and writes to it reach the original value. Returning V<T> allocates a new value.
  • There is one function per name: registering a name again replaces the function. For mixed operands accept a Union, i.e. rhs: Union<R<Vec3>, f32>.
  • Mutate in place by taking M<Self>; pure functions return new values.

Documentation

Doc comments end up in the generated docs and in editor declaration files, and are read by script writers rather than Rust developers:

  • start with one short sentence, and only describe the arguments when they are not obvious
  • avoid Rust specific terms, i.e. say “or nil” rather than Option
  • link bevy types using their full Rust path, i.e. [`Vec3`](glam::Vec3), these will be resolved to the bevy docs

Examples

Keep examples short and only add them where they help. Write one block per language, one after the other, using the multi-lang-example code block attribute followed by the language:

```multi-lang-example,lua
local Vec3 = import_namespace("math").Vec3
local v = Vec3.new(1, 2, 3)
assert(v.x == 1)
```

```multi-lang-example,rune
let Vec3 = import_namespace("math").Vec3;
let v = Vec3.new(1, 2, 3);
assert!(v.x == 1.0);
```

which renders as a single block with a tab per language:

local Vec3 = import_namespace("math").Vec3
local v = Vec3.new(1, 2, 3)
assert(v.x == 1)
let Vec3 = import_namespace("math").Vec3;
let v = Vec3.new(1, 2, 3);
assert!(v.x == 1.0);

Examples are tests: they must run as written and check their own results with assert. Every multi-lang-example block in the doc comments under crates/ and in the book is run by the doc_example_tests test, with the scenario in assets/doc_examples/default.bmsscenario (the same app as the script tests):

cargo test --test doc_example_tests --features lua54,rune,bevy_math_bindings -- math

Examples of a bindings crate whose feature is disabled are ignored. If an example needs a different setup, i.e. a window, name a scenario with the scenario attribute, i.e. multi-lang-example,lua,scenario=window, which refers to assets/doc_examples/window.bmsscenario. Mark examples which can’t run in a test app with ignore, i.e. multi-lang-example,lua,ignore, and say what they need in the surrounding docs.

Tests

Each bindings crate has its script tests under assets/tests/bindings/<category>/, with a script per language per type or topic, i.e. assets/tests/bindings/math/vec.lua and assets/tests/bindings/math/vec.rn. Run them with:

cargo test --test script_tests --features lua54,rune -- bindings/math

Adding New Languages to BMS

If you are interested in adding a new language to BMS, please read this section first. Adding a new language is a non-trivial task depending on the language you want to add. It also requires a lot of effort and time to maintain a new language, so unless the language you want to add is widely used and has a large community, it might not be worth the effort.

Evaluating Feasibility

In order for a language to work well with BMS it’s necessary it supports the following features:

  • Interoperability with Rust. If you can’t call it from Rust easilly and there is no existing crate that can do it for you, it’s a no-go.
  • First class functions. Or at least the ability to call an arbitrary function with an arbitrary number of arguments from a script. Without this feature, you would need to separately generate code for the bevy bindings which is painful and goes against the grain of BMS.

First Classs Functions

They don’t necessarily have to be first class from the script POV, but they need to be first class from the POV of the host language. This means that the host language needs to be able to call a function with an arbitrary number of arguments.

Examples

Let’s say your language supports a Value type which can be returned to the script. And it has a Value::Function variant. The type on the Rust side would look something like this:

pub enum Value {
    Function(Arc<Fn(&[Value]) -> Value>),
    // other variants
}

This is fine, and can be integrated with BMS. Since an Fn function can be a closure capturing a DynamicScriptFunction. If there is no support for FnMut closures though, you might face issues in the implementation. Iterators in bevy_mod_scripting_functions for example use DynamicScriptFunctionMut which cannot work with Fn closures.

Now let’s imagine instead another language with a similar enum, supports this type instead:

#![allow(unused)]
fn main() {
pub enum Value {
    Function(Arc<dyn Function>),
    // other variants
}

pub trait Function {
    fn call(&self, args: Vec<Value>) -> Value;

    fn num_params() -> usize;
}
}

This implies that to call this function, you need to be able to know the amount of arguments it expects at COMPILE time. This is not compatibile with dynamic functions, and would require a lot of code generation to make work with BMS. Languages with no support for dynamic functions are not compatible with BMS.

Interoperability with Rust

Not all languages can easilly be called from Rust. Lua has a wonderful crate which works out the ffi and safety issues for us. But not all languages have this luxury. If you can’t call it from Rust easilly and there is no existing crate that can do it for you, integrating with BMS might not be the best idea.

Necessary Features

In order for a language to be called “implemented” in BMS, it needs to support the following features.

Values

Every ScriptValue variant needs a counterpart in the language, in both directions. Two of them are handles rather than data:

  • ScriptValue::Reference: a reference to a reflected value, usually a userdata/custom type wrapping ReflectReference.
  • ScriptValue::Type: a type itself, i.e. what scripts use to reach a type’s static members. It carries only a TypeId and never allocates.

Every context gets the builtins as globals, nothing else: bevy_mod_scripting_bindings::builtins::builtins() (import_namespace, export_namespace) plus the language’s own register_callback:

for (name, function) in builtins() {
    context.globals().set(name, LuaScriptValue::from(ScriptValue::Function(function)))?;
}

Script handlers, loaders etc. must be implemented such that the ThreadWorldContainer is set for every interaction with script contexts, or anywhere else it might be needed.

Dispatching to Rust

All lookup rules live in bevy_mod_scripting_bindings::dispatch; a language maps its operators and metamethods onto it, and converts the values:

Script operationdispatch function
v.name, v[key]index, returns Member::Method or Member::Static
v.name = xset_index
Type.name on a ScriptValue::Typestatic_index
v + x, -, *, /, %, ^, ==, <binary with the matching ScriptOperatorNames (dispatches to add, sub, mul, div, rem, pow, eq, lt)
2 * v (value on the right)binary too, which calls the operator’s reflected function (mul, rsub, …)
-vunary with Negation (neg)
#vlen (lists directly, references through len)
iterationiter, returns a function to call until it returns ScriptValue::Unit
printingdisplay / debug

Receivers

index returns functions which are called on the indexed value as Member::Method, without the value bound to them. Delivering the receiver is the language’s job:

  • Lua passes it with its colon syntax, v:length(), so the function is returned as is.
  • Rune has method syntax, but resolves v.name by a table fixed when its context is built, so every identifier in the script is registered when it is compiled (and v["name"] always works), see bevy_mod_scripting_rune::types. The receiver is passed to the function as the first argument.

Static members

Type.name resolves, in order, to:

  1. functions registered on the type itself
  2. functions shared by all types (registered on StaticTypeRef, i.e. the new constructor), with the type bound as their first argument by DynamicScriptFunction::bind_to_type
  3. the type’s enum variants

Types reach scripts in two forms, which resolve static members the same way:

  • ScriptValue::Type, i.e. world (import_namespace("bms").world), indexed with dispatch::static_index
  • type registrations, i.e. the entries of import_namespace, which are references and are indexed with dispatch::index like any other value

Binding the type is done by BMS, so languages never handle StaticTypeRef arguments themselves.

RFC’s

An RFC is a request for comments from contributors, users and various other stakeholders. When an RFC is created it is usually done with the intention of gathering opinions and knowledge around the topic.

for BMS the process looks as follows:

  • An RFC is created and modified wia PR’s to the RFC file under docs/RequestsForComments/XXX-RFCTITLE/XX-RFCTITLE.md.
  • The creator of an RFC also starts an issue for discussion of the RFC on github linking to the file.
  • Once happy enough perspecties are gathered an RFC can be closed and the decision implemented.

Abandoning Codegen

Summary

Codegen has played a big role from the start for BMS, giving us great benefits, but mainly the ability to quickly ‘sync’ our scripting API with each new bevy release (instead of a manual review each time).

This was especially important before the introduction of a unified scripting function registry, which would have meant writing a version of each API per language.

However, I believe that as Bevy is maturing, the APIs that people rely on are likely to be more stable than ever, and I have a hypothesis that a large majority of the generated bindings are simply left unused.

The other side of the coin is that codegen is somewhat problematic due to:

  • Largely increased compilation times
  • The need to stay in sync with the rustc codebase (the compiler internals we use to plug into the compilation)

I believe it’s time to finally abandon this concept, and commit to hand writing a core scripting API over the important parts of bevy.

Status Quo

A little context for those who are not aware of how codegen works in our case.

Automatic Bindings

The code under /codegen contains crates which create a custom cargo executable (a driver and the entry point). This works with cargo to execute a custom rustc compilation, which on top of compiling and error checking the code, also runs our custom hooks.

In these hooks we scan through the available types and generate artifacts as we go (caches and lookups), which are then used to render code templates. All of the crates found under crates/bindings are fully rendered via this process.

These templates direct the generator to produce #[script_bindings] invocations, just as if they were handwritten, based on the functions available.

The process is slightly limited due to the presence of generics and other rust quirks which can’t be handled automatically, e.g. fn hello<A: ToString>(a: A) wouldn’t work, even though it’s somewhat trivial to deal with by hand.

At the end we are left with tonnes of bindings crates for all the important bevy crates.

An example can be seen in our book with the SRGBA struct:

Note that the docgen is not tied to codegen, the same documentation would be produced if you manually wrote the script bindings macro invocations yourself.

Existing Manual Bindings

Not all of our bindings are automatically generated like this however. The crate bevy_mod_scripting_functions contains a load of hand-written core types and functions, like World::get_type_by_name or World::get_component, and way more.

These already live happily alongside the generated bindings, and are the model for what this RFC proposes we do everywhere.

Motivation

With the above in mind, I form the following hypotheses:

  • Automatically generated bindings are okay at best, with many functions missing and docs mentioning rust constructs explicitly (since they come directly from docstrings)
  • Most of them are unused
  • The lack of functionality for generating bindings for 3rd party libraries means the codegen is not as useful as it could be
  • Bevy’s API is stabilizing, and upcoming work on enums and constructors will make many bindings unnecessary anyway

Proposal

Based on the above, I propose the following:

  • Handwriting binding crates with high quality multi language docstrings
  • Empowering the community to build their own bindings crates for their favourite libraries

In this new world we would focus on writing the most critical pieces of integration with bevy. Instead of putting in effort to maintain a bespoke rustc compiler plugin, we could provide github action templates to let people build out bindings quickly.

Migration

The codegen runs on our side, not on the consumer’s machine, and its output is committed. So no feature flag or default-on/off transition is needed:

  1. Remove the codegen project, keeping whatever it last generated as plain source.
  2. Iterate on and clean up those bindings, deleting ones that are no longer needed as the enum and constructor work lands.

This starts from a non-breaking state, and I’d like to begin as early as the 0.20 cycle rather than waiting for the editor.

Bindings for 3rd party libraries (e.g. bevy_hanabi, UI, physics) would not live in core, which would only keep Bevy-native bindings. Instead we’d make it easy to set up small community bindings crates that sync to the main test suite and publish easily.

Alternatives

We could also of course make our current codegen better, more flexible and generally stronger, however some of its core problems will always remain (like bad documentation at best, and long compilation times).

Benefits

  • Clean compilation times have potential to go down by as much as 10 minutes (on my machine), which also makes clean CI builds cheaper
  • Bevy bindings quality increases, and a smaller API surface is easier for beginners
  • Intermediate file sizes decrease (i.e. LAD files, LUA declaration files)

Drawbacks

  • Each bevy version upgrade might take longer, due to the need to identify API surface changes. However, this should be fairly well mitigated by our test suite and also thanks to AI tools nowadays
  • Potentially smaller (but hopefully higher quality) API surface immediately after the switch