Duplicate registers the new resource

This commit is contained in:
b-guild
2025-10-19 04:53:13 -07:00
parent 1efe57c471
commit fa610c7e77
3 changed files with 23 additions and 4 deletions
+13 -3
View File
@@ -449,8 +449,14 @@ impl AssetItemContextMenu {
match File::create(&final_copy_path) {
Ok(mut file) => {
Log::verify(file.write_all(&data_source.bytes));
let result = file.write_all(&data_source.bytes);
drop(file);
if result.is_ok() {
engine
.resource_manager
.request_untyped(&final_copy_path);
}
Log::verify(result);
sender
.send(Message::ShowInAssetBrowser(final_copy_path));
}
@@ -472,7 +478,11 @@ impl AssetItemContextMenu {
let ext = ext.to_string_lossy().to_string();
let final_copy_path =
asset::make_unique_path(parent, &stem, &ext);
Log::verify(std::fs::copy(canonical_path, final_copy_path));
let result = std::fs::copy(canonical_path, &final_copy_path);
if result.is_ok() {
engine.resource_manager.request_untyped(final_copy_path);
}
Log::verify(result);
}
}
}
+10
View File
@@ -2967,6 +2967,15 @@ impl Editor {
self.engine.destroy_graphics_context().unwrap();
}
fn on_focus_changed(&mut self) {
if self.focused {
self.engine
.resource_manager
.state()
.process_filesystem_events();
}
}
pub fn run(mut self, event_loop: EventLoop<()>) {
Log::info("Initializing resource registry.");
self.engine.resource_manager.update_or_load_registry();
@@ -3047,6 +3056,7 @@ impl Editor {
}
WindowEvent::Focused(focused) => {
self.focused = *focused;
self.on_focus_changed();
}
WindowEvent::Moved(new_position) => {
// Allow the window to go outside the screen bounds by a little. This
-1
View File
@@ -1297,7 +1297,6 @@ impl ResourceManagerState {
true
}
});
self.process_filesystem_events();
}
fn add_resource_and_notify(&mut self, resource: UntypedResource) {