无法设置按钮颜色

Can't set button color

基于 this UI example 我在 on_start 方法的末尾添加了一个自定义按钮。但是当我 运行 游戏时按钮主体是不可见的,只显示它的文本 ("1234567")。

我添加到示例中的代码:

// ...

use amethyst::assets::AssetStorage;
use amethyst::assets::Handle;
use amethyst::assets::Loader;
use amethyst::renderer::loaders::load_from_srgba;
use amethyst::renderer::palette::Srgba;
use amethyst::renderer::Texture;
use amethyst::renderer::types::TextureData;
use amethyst::ui::Anchor;
use amethyst::ui::UiButtonBuilder;
use amethyst::ui::UiImage;

// ...

impl SimpleState for Example {
    fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>) {
        // ...

        let texture_handle: Handle<Texture> = {
            let loader = world.read_resource::<Loader>();
            let texture_assets = world.read_resource::<AssetStorage<Texture>>();
            let texture_builder = load_from_srgba(Srgba::new(0.8, 0.6, 0.3, 1.0));
            loader.load_from_data(TextureData::from(texture_builder), (), &texture_assets)
        };

        let button = UiButtonBuilder::<(), u32>::new("1234567".to_string())
            .with_id(666)
            .with_font_size(12.0)
            .with_position(64.0, -64.0)
            .with_size(64.0 * 3.0, 64.0)
            .with_anchor(Anchor::TopMiddle)
            // HAS NO EFFECT
            .with_image(texture_handle)
            // HAS NO EFFECT
            .with_hover_image(UiImage::SolidColor([0.1, 0.1, 0.1, 0.5]))
            .with_layer(12.0)
            .build_from_world(&world);

        world.insert(button);
    }
}

// ...

使用自定义颜色即时创建按钮的正确方法是什么?

我正在使用紫水晶 v0.15。

UiButtonBuilder 存在错误。我刚刚创建了这个问题:https://github.com/amethyst/amethyst/issues/2298