mesh filter
This commit is contained in:
42
unity-parser/src/types/unity_types/mesh_filter.rs
Normal file
42
unity-parser/src/types/unity_types/mesh_filter.rs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
//! MeshFilter component wrapper
|
||||||
|
|
||||||
|
use crate::types::{yaml_helpers, ComponentContext, FileRef, UnityComponent};
|
||||||
|
use sparsey::Entity;
|
||||||
|
|
||||||
|
/// A MeshFilter component
|
||||||
|
///
|
||||||
|
/// MeshFilter holds a reference to a mesh asset that is used by the MeshRenderer.
|
||||||
|
/// It defines the geometry that will be rendered for a GameObject.
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub struct MeshFilter {
|
||||||
|
mesh: Option<FileRef>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MeshFilter {
|
||||||
|
/// Get the mesh reference
|
||||||
|
pub fn mesh(&self) -> Option<&FileRef> {
|
||||||
|
self.mesh.as_ref()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Set the mesh reference
|
||||||
|
pub fn set_mesh(&mut self, mesh: Option<FileRef>) {
|
||||||
|
self.mesh = mesh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl UnityComponent for MeshFilter {
|
||||||
|
/// Parse a MeshFilter from YAML
|
||||||
|
///
|
||||||
|
/// Note: Caller is responsible for ensuring this is called on the correct document type.
|
||||||
|
fn parse(yaml: &serde_yaml::Mapping, _ctx: &ComponentContext) -> Option<Self> {
|
||||||
|
let mesh = yaml_helpers::get_file_ref(yaml, "m_Mesh");
|
||||||
|
|
||||||
|
Some(Self { mesh })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl crate::types::EcsInsertable for MeshFilter {
|
||||||
|
fn insert_into_world(self, world: &mut sparsey::World, entity: Entity) {
|
||||||
|
world.insert(entity, (self,));
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user