pub struct YoleckEntityRef { /* private fields */ }Expand description
A reference to another Yoleck entity, stored by UUID for persistence.
This allows one entity to reference another entity in a way that survives saving and loading.
The reference is stored as a UUID in the level file, which gets resolved to an actual Entity
at runtime.
§Requirements
Important: Only entities with .with_uuid() can be referenced. When defining entity types
that should be referenceable, make sure to add .with_uuid() to the entity type:
app.add_yoleck_entity_type({
YoleckEntityType::new("Planet")
.with_uuid() // Required for entity references!
// ... other configuration
});§Editor Features
In the editor, entity references can be set using:
- Dropdown menu to select from available entities
- Drag and drop from the entity list (only entities with UUID can be dragged)
- Viewport click selection using the 🎯 button
§Usage
Add a YoleckEntityRef field to your component with the entity_ref attribute to filter by
entity type:
#[derive(Component, YoleckComponent, YoleckAutoEdit, Serialize, Deserialize, Clone, PartialEq, Default)]
struct LaserPointer {
#[yoleck(entity_ref = "Planet")]
target: YoleckEntityRef,
}Implementations§
Source§impl YoleckEntityRef
impl YoleckEntityRef
pub fn new() -> Self
pub fn from_uuid(uuid: Uuid) -> Self
pub fn is_some(&self) -> bool
pub fn is_none(&self) -> bool
pub fn entity(&self) -> Option<Entity>
pub fn uuid(&self) -> Option<Uuid>
pub fn clear(&mut self)
pub fn set(&mut self, uuid: Uuid)
pub fn resolve( &mut self, registry: &YoleckUuidRegistry, ) -> Result<(), YoleckEntityRefCannotBeResolved>
Trait Implementations§
Source§impl Clone for YoleckEntityRef
impl Clone for YoleckEntityRef
Source§fn clone(&self) -> YoleckEntityRef
fn clone(&self) -> YoleckEntityRef
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for YoleckEntityRef
impl Debug for YoleckEntityRef
Source§impl Default for YoleckEntityRef
impl Default for YoleckEntityRef
Source§fn default() -> YoleckEntityRef
fn default() -> YoleckEntityRef
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for YoleckEntityRef
impl<'de> Deserialize<'de> for YoleckEntityRef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for YoleckEntityRef
impl Hash for YoleckEntityRef
Source§impl PartialEq for YoleckEntityRef
impl PartialEq for YoleckEntityRef
Source§impl Serialize for YoleckEntityRef
impl Serialize for YoleckEntityRef
Source§impl YoleckAutoEdit for YoleckEntityRef
impl YoleckAutoEdit for YoleckEntityRef
fn auto_edit(value: &mut Self, ui: &mut Ui)
Source§fn auto_edit_field_impl(
value: &mut Self,
ui: &mut Ui,
label: &str,
attrs: &FieldAttrs,
)
fn auto_edit_field_impl( value: &mut Self, ui: &mut Ui, label: &str, attrs: &FieldAttrs, )
Internal implementation for field rendering with label
Types can override this to customize behavior based on attributes
Source§fn auto_edit_with_label_and_attrs(
value: &mut Self,
ui: &mut Ui,
label: &str,
attrs: &FieldAttrs,
)
fn auto_edit_with_label_and_attrs( value: &mut Self, ui: &mut Ui, label: &str, attrs: &FieldAttrs, )
Auto-edit with field-level attributes (label, tooltip, range, etc.)
Default implementation wraps auto_edit with label and common decorations
impl Eq for YoleckEntityRef
impl StructuralPartialEq for YoleckEntityRef
Auto Trait Implementations§
impl Freeze for YoleckEntityRef
impl RefUnwindSafe for YoleckEntityRef
impl Send for YoleckEntityRef
impl Sync for YoleckEntityRef
impl Unpin for YoleckEntityRef
impl UnwindSafe for YoleckEntityRef
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
Return the
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DynEq for T
impl<T> DynEq for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T> FromWorld for Twhere
T: Default,
impl<T> FromWorld for Twhere
T: Default,
§fn from_world(_world: &mut World) -> T
fn from_world(_world: &mut World) -> T
Creates Self using default().
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
§impl<T> TypeData for T
impl<T> TypeData for T
§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.