#Bevy Scene Empty

9 messages · Page 1 of 1 (latest)

stray steeple
#
(
  resources: {},
  entities: {},
)
rocky pagoda
#

DynamicSceneBuilder needs a list of entities and resources to replicate

stray steeple
#

ooh thx

stray steeple
#

Err(Message("type bevy_platform::sync::Arc<core::sync::atomic::AtomicBool> did not register the ReflectSerialize or ReflectSerializeWithRegistry type data. For certain types, this may need to be registered manually using register_type_data (stack: bevy_a11y::AccessibilityRequested -> bevy_platform::sync::Arc<core::sync::atomic::AtomicBool>)"))

stray steeple
#
fn save_world(
    world: &mut World,
) {
    let mut query = world.query_filtered::<Entity, With<ComponentA>>();
    let mut hash_set = HashSet::new();
    hash_set.insert(TypeId::of::<ResourceA>());

    let scene = DynamicSceneBuilder::from_world(world).extract_entities(
        query.iter(world)
    )
        .with_resource_filter(SceneFilter::Allowlist(hash_set))
        .extract_resources()
        .build();
    let type_registry = world.resource::<AppTypeRegistry>().read();

    let serialized = scene.serialize(&type_registry).unwrap();
    info!("{:?}", serialized);
    IoTaskPool::get()
        .spawn(async move {
            // Write the scene RON data to file
            File::create(format!("assets/scene_{}.ron", chrono::Utc::now().timestamp()))
                .and_then(|mut file| file.write(serialized.as_bytes()))
                .expect("Error while writing scene to file");
        })
        .detach();
}

it worked

rocky pagoda
#

maybe better to deny_all_resources().allow_resource::<>()