Struct bevy_inspector_egui::Context
source · pub struct Context<'a> {
pub ui_ctx: Option<&'a Context>,
pub id: Option<u64>,
/* private fields */
}
Expand description
The context passed to Inspectable::ui
.
Fields§
§ui_ctx: Option<&'a Context>
egui ui context
id: Option<u64>
Something to distinguish between siblings.
Implementations§
source§impl<'a> Context<'a>
impl<'a> Context<'a>
sourcepub fn world(&self) -> Option<&'a World>
pub fn world(&self) -> Option<&'a World>
Returns a reference to the world if the context has access to it
sourcepub unsafe fn world_mut(&mut self) -> Option<&'a mut World>
pub unsafe fn world_mut(&mut self) -> Option<&'a mut World>
Get a mutable reference to the world
if the inspector has access to it.
Safety
Users of this function are only allowed to mutate resources and components, but can’t do any changes that would result in changes of archetypes.
sourcepub fn world_scope(
&mut self,
ui: &mut Ui,
ty: &str,
f: impl FnOnce(&mut World, &mut Ui, &mut Context<'_>) -> bool
) -> bool
pub fn world_scope(
&mut self,
ui: &mut Ui,
ty: &str,
f: impl FnOnce(&mut World, &mut Ui, &mut Context<'_>) -> bool
) -> bool
Returns the provided closure with mutable access to the world, and a context that has no access to the world.
Will display an error message if the context doesn’t have world access.
sourcepub unsafe fn world_scope_unchecked(
&mut self,
ui: &mut Ui,
ty: &str,
f: impl FnOnce(&mut World, &mut Ui, &mut Context<'_>) -> bool
) -> bool
pub unsafe fn world_scope_unchecked(
&mut self,
ui: &mut Ui,
ty: &str,
f: impl FnOnce(&mut World, &mut Ui, &mut Context<'_>) -> bool
) -> bool
Like Context::world_scope
, but the context will have world access as well.
Safety
The function must not use the world in ways that would invalidate archetypes, as
types like the InspectorQuery
will rely on them being the same before and after
calling Inspectable::ui
.
sourcepub fn resource_scope<T: Resource, F: FnOnce(&mut Ui, &mut Context<'_>, Mut<'_, T>) -> bool>(
&mut self,
ui: &mut Ui,
ty: &str,
f: F
) -> bool
pub fn resource_scope<T: Resource, F: FnOnce(&mut Ui, &mut Context<'_>, Mut<'_, T>) -> bool>(
&mut self,
ui: &mut Ui,
ty: &str,
f: F
) -> bool
Temporarily removes a resource from the world and calls the provided closure with that resource
while still having &mut Context
available.
Will display an error message if the context doesn’t have world access.
source§impl<'a> Context<'a>
impl<'a> Context<'a>
sourcepub fn new_world_access(
ui_ctx: Option<&'a Context>,
world: &'a mut World
) -> Self
pub fn new_world_access(
ui_ctx: Option<&'a Context>,
world: &'a mut World
) -> Self
Create a new context with access to the world
Creates a context without access to World
sourcepub fn with_world(&self, world: &'a mut World) -> Self
pub fn with_world(&self, world: &'a mut World) -> Self
Same context but with different world
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Context<'a>
impl<'a> !Send for Context<'a>
impl<'a> !Sync for Context<'a>
impl<'a> Unpin for Context<'a>
impl<'a> !UnwindSafe for Context<'a>
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
impl<T, U> AsBindGroupShaderType<U> for Twhere
U: ShaderType,
&'a T: for<'a> Into<U>,
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U
T
[ShaderType
] for self
. When used in [AsBindGroup
]
derives, it is safe to assume that all images in self
exist. Read more§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more