-
So, I want to make a plugin that needs to load a spritesheet specified by the user. At first I thought I could just add the path directly in the Plugin struct, but the plugin builder doesn't have, as far as I know, a way to use the asset server. So, I'm not sure what would be the recommended approach here. Should I just make a NameOfPluginSettings Resource and ask the user to insert that? Is there maybe a way to query for the Plugin struct? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
We currently recommend (and use internally) the "plugin settings as resource" pattern. For example, the official LogPlugin looks like this: struct LogPlugin;
pub struct LogSettings {
pub filter: String,
pub level: Level,
}
impl Plugin for LogPlugin {
fn build(&self, app: &mut AppBuilder) {
let settings = app.world_mut().get_resource_or_insert_with(LogSettings::default);
// initialize plugin
}
} We encourage this pattern for a few reasons:
|
Beta Was this translation helpful? Give feedback.
We currently recommend (and use internally) the "plugin settings as resource" pattern. For example, the official LogPlugin looks like this:
We encourage this pattern for a few reasons: