Trait MaterializeAppExt

Source
pub trait MaterializeAppExt {
    // Required methods
    fn register_generic_material<M: Material + Reflect + Struct + FromWorld + GetTypeRegistration>(
        &mut self,
    ) -> &mut Self;
    fn register_generic_material_with_default<M: Material + Reflect + Struct + GetTypeRegistration>(
        &mut self,
        default_value: M,
    ) -> &mut Self;
    fn register_generic_material_shorthand<M: GetTypeRegistration>(
        &mut self,
        shorthand: impl Into<String>,
    ) -> &mut Self;
}

Required Methods§

Source

fn register_generic_material<M: Material + Reflect + Struct + FromWorld + GetTypeRegistration>( &mut self, ) -> &mut Self

Register a material to be able to be created via GenericMaterial.

This also registers the type if it isn’t already registered.

It’s also worth noting that from_world is only called once when the material is registered, then that value is cloned each time a new instance is required.

Source

fn register_generic_material_with_default<M: Material + Reflect + Struct + GetTypeRegistration>( &mut self, default_value: M, ) -> &mut Self

Same as register_generic_material, but with a provided default value.

This main use of this is for extended materials, allowing you to specify defaults for the base material that you wouldn’t be able to otherwise.

Source

fn register_generic_material_shorthand<M: GetTypeRegistration>( &mut self, shorthand: impl Into<String>, ) -> &mut Self

If your material name is really long, you can use this to register a shorthand that can be used in place of it.

This is namely useful for extended materials, as those type names tend to have a lot of boilerplate.

§Examples
.register_generic_material_shorthand::<YourOldReallyLongNameOhMyGoshItsSoLong>("ShortName")

Now you can turn

type = "YourOldReallyLongNameOhMyGoshItsSoLong"

into

type = "ShortName"

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl MaterializeAppExt for App

Source§

fn register_generic_material<M: Material + Reflect + Struct + FromWorld + GetTypeRegistration>( &mut self, ) -> &mut Self

Source§

fn register_generic_material_with_default<M: Material + Reflect + Struct + GetTypeRegistration>( &mut self, default_value: M, ) -> &mut Self

Source§

fn register_generic_material_shorthand<M: GetTypeRegistration>( &mut self, shorthand: impl Into<String>, ) -> &mut Self

Implementors§