12个不稳定版本 (5个破坏性更新)

0.7.1 2020年8月23日
0.7.0 2020年6月4日
0.6.1 2020年2月10日
0.6.0 2019年11月19日
0.1.0 2018年12月8日

#1369 in 游戏开发


3 个Crate 中使用

CC0 许可证

1MB
696

Documentation on docs.rs

amethyst-imgui

Amethyst-imgui为Amethyst游戏引擎提供了对imgui-rs crate的集成。

ImGUI以其在快速原型设计和调试界面中的实用性而闻名于整个行业。

集成

此crate提供了一个amethyst RenderPlugin(自amethyst 0.12以来可用),该插件可以正确渲染使用imgui-rs crate渲染的ImGUI窗口。此集成是通过在Amethyst(一个SystemState是合适的地方)内部调用amethyst_imgui::with函数来实现的,它将在ImGui的即时模式上下文中进行渲染。所有同步、帧处理和Amethyst输入都由这个crate处理。

一个最小示例可以在examples/demo_window.rs找到

# For Windows/Linux:
cargo run --example demo_window --features vulkan
# For MacOS:
cargo run --example demo_window --features metal

用法

此crate当前需要包含amethyst crate;这可能会导致amethyst完全重新编译,因为特性不同。如果是这种情况,您需要克隆此git仓库并设置适当的功能。

此crate使用amethyst shader-compiler,该编译器依赖于shaderc在构建时编译其着色器。最后,此crate公开与amethyst相同的渲染功能,并将它们传递给amethyst。

示例Cargo.toml用法

amethyst-imgui = { version = "0.7", features = ["vulkan"] }

RenderPlugin使用示例

fn main() -> amethyst::Result<()> {
    amethyst::start_logger(Default::default());
    let app_root = application_root_dir()?;
    let display_config_path = app_root.join("examples/display.ron");

    let game_data = GameDataBuilder::default()
        .with_barrier()
        .with(DemoSystem::default(), "imgui_use", &[])
        .with_bundle(amethyst::input::InputBundle::<amethyst::input::StringBindings>::default())?
        .with_bundle(
            RenderingBundle::<DefaultBackend>::new()
                .with_plugin(
                    RenderToWindow::from_config_path(display_config_path)
                        .with_clear([0.34, 0.36, 0.52, 1.0]),
                )
                .with_plugin(RenderImgui::<amethyst::input::StringBindings>::default()),
        )?;

    Application::build("/", Example)?.build(game_data)?.run();

    Ok(())
}

使用amethyst-imgui的示例System

pub struct ImguiDemoSystem;
impl<'s> amethyst::ecs::System<'s> for ImguiDemoSystem {
    type SystemData = ();
    fn run(&mut self, _: Self::SystemData) {
        amethyst_imgui::with(|ui| {
            ui.show_demo_window(&mut true);
        });
    }
}

依赖项

~49–68MB
~1M SLoC