pub struct SceneLoader;Expand description
Static helper methods for loading and unloading scenes.
Implementations§
Source§impl SceneLoader
impl SceneLoader
Sourcepub fn load_scene(
manager: &mut SceneManager,
name: &str,
data: SceneData,
) -> Result<SceneId, GoudError>
pub fn load_scene( manager: &mut SceneManager, name: &str, data: SceneData, ) -> Result<SceneId, GoudError>
Sourcepub fn unload_scene(
manager: &mut SceneManager,
name: &str,
) -> Result<(), GoudError>
pub fn unload_scene( manager: &mut SceneManager, name: &str, ) -> Result<(), GoudError>
Unloads a scene by name.
Looks up the scene by name and destroys it. Dropping the
[World] cleans up all entities and components.
§Errors
Returns an error if:
- No scene with the given name exists
- The scene is the default scene (which cannot be destroyed)
Sourcepub fn load_scene_from_json(
manager: &mut SceneManager,
name: &str,
json: &str,
) -> Result<SceneId, GoudError>
pub fn load_scene_from_json( manager: &mut SceneManager, name: &str, json: &str, ) -> Result<SceneId, GoudError>
Loads a scene from a JSON string.
Parses the JSON into SceneData, then delegates to
load_scene.
§Errors
Returns an error if:
- The JSON is invalid or does not match the expected schema
- Scene creation or deserialization fails
Sourcepub fn save_scene_to_json(
manager: &SceneManager,
id: SceneId,
) -> Result<String, GoudError>
pub fn save_scene_to_json( manager: &SceneManager, id: SceneId, ) -> Result<String, GoudError>
Saves a scene to a JSON string.
Serializes all entities and components in the scene’s world, then converts to a pretty-printed JSON string.
§Errors
Returns an error if:
- The scene ID does not exist
- Serialization fails
Auto Trait Implementations§
impl Freeze for SceneLoader
impl RefUnwindSafe for SceneLoader
impl Send for SceneLoader
impl Sync for SceneLoader
impl Unpin for SceneLoader
impl UnsafeUnpin for SceneLoader
impl UnwindSafe for SceneLoader
Blanket Implementations§
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
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