egui_overlay icon indicating copy to clipboard operation
egui_overlay copied to clipboard

How to use eframe storage?

Open FreePhoenix888 opened this issue 1 year ago • 1 comments

In eframe we are able to use storage: https://docs.rs/eframe/0.26.2/eframe/index.html#:~:text=app%20state%20using-,cc.storage,-(requires%20the%20%22persistence

How to do it when using egui_overlay?

FreePhoenix888 avatar Feb 29 '24 18:02 FreePhoenix888

you just serialize egui memory struct from the context using ctx.memory(|mem| serialize(mem)) and save it to a file. And then load it when starting your app, deserialize it (or create default) and assign it to context using ctx.memory_mut()

https://github.com/emilk/egui/blob/master/crates/eframe/src/native/epi_integration.rs#L348 shows you how eframe does it.

coderedart avatar Feb 29 '24 19:02 coderedart