This commit is contained in:
1 parent
d038cf3670
commit
ba59f57a5a
11 files changed
+466
-156
No files matched your search
@@ -22,6 +22,7 @@ use crate::asset_db::{ensure_asset_record, AssetRegistry};
|
||||
use crate::history::{
|
||||
capture_prefab_edit_state, record_prefab_edit_state, record_prefab_source_apply,
|
||||
};
|
||||
use crate::native_dialog::NativeDialogBroker;
|
||||
use crate::ui::inspector::{
|
||||
apply_component_card_response, component_card, component_card_context, property_row,
|
||||
ComponentCardOptions,
|
||||
@@ -751,13 +752,44 @@ fn relink_prefab_source(world: &mut World, entity: Entity) {
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let Some(path) = rfd::FileDialog::new()
|
||||
.set_directory(project_root.join("assets/prefabs"))
|
||||
.add_filter("Bevy prefab", &["scn.ron", "ron"])
|
||||
.pick_file()
|
||||
else {
|
||||
let directory = project_root.join("assets/prefabs");
|
||||
let result = world.resource::<NativeDialogBroker>().request(
|
||||
move || {
|
||||
rfd::FileDialog::new()
|
||||
.set_directory(directory)
|
||||
.add_filter("Bevy prefab", &["scn.ron", "ron"])
|
||||
.pick_file()
|
||||
},
|
||||
move |world, path| {
|
||||
let Some(path) = path else {
|
||||
world
|
||||
.resource_mut::<crate::scene_io::SceneIo>()
|
||||
.set_status("Prefab relink cancelled");
|
||||
return;
|
||||
};
|
||||
finish_relink_prefab_source(world, entity, project_root, path);
|
||||
},
|
||||
);
|
||||
world
|
||||
.resource_mut::<crate::scene_io::SceneIo>()
|
||||
.set_status(match result {
|
||||
Ok(()) => "Choose a prefab source".into(),
|
||||
Err(error) => format!("Prefab relink unavailable: {error}"),
|
||||
});
|
||||
}
|
||||
|
||||
fn finish_relink_prefab_source(
|
||||
world: &mut World,
|
||||
entity: Entity,
|
||||
project_root: PathBuf,
|
||||
path: PathBuf,
|
||||
) {
|
||||
if world.get_entity(entity).is_err() {
|
||||
world
|
||||
.resource_mut::<crate::scene_io::SceneIo>()
|
||||
.set_status("Prefab relink failed: the initiating actor no longer exists");
|
||||
return;
|
||||
};
|
||||
}
|
||||
let Ok(path) = path.canonicalize() else {
|
||||
return;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user