Crate bevy_cobweb_ui

Source
Expand description

§Bevy Cobweb UI

A UI and asset-management framework for the bevy game engine.

Depends on bevy and bevy_cobweb.

§Features

§Getting Started

Check out the bevy_cobweb_ui book, which is a guide tailored to new users.

(Optional) Install syntax highlighting for the COB asset format.

Check the loading module docs for how to write COB files. COB files can be hot reloaded with the hot_reload feature. Hot-reloaded changes will cause affected scene nodes to be refreshed (or cause commands to be re-applied). Hot-reloading is minimally destructive. Entities are only despawned when you delete scene nodes from a COB file.

Check the repository examples for how to build different kinds of UI.

§Examples

  • hello_world: Bare-bones hello world.
  • Built-in widgets:
  • cursors: Set custom cursors that respond to interactions with UI elements.
  • fonts: Register new fonts and use them to set text.
  • help_text: Help text that appears on hover. Showcases PropagateOpacity, which allows controlling (and animating) the opacity of entire node trees, and even layering multiple PropagateOpacity within a single tree.
  • localization: Showcases localized text and font.
  • calculator: A basic calculator. Shows how to use grid layout and scene macros.
  • counter: Simple counter button. Shows how ControlRoot and ControlMember can be used to transfer interactions within a widget. Also demonstrates updating text dynamically on the code side.
  • game_menu: A simple game menu with settings page. Showcases multiple uses of built-in radio buttons, sliders, and drop-downs, localization, non-interactive animations, and how to manage localized image assets using COB files as asset manifests.
    • Not yet migrated to use COB. It is waiting for a dropdown widget to be implemented.
  • editor_demo: Showcases the editor with custom editor widgets.

§Editor

There is an editor, enabled by the editor feature. It is currently a very basic proof of concept, and may or may not be developed further. See the editor_demo example.

§Raw COB

The COB value format can also be used for plain config files. To parse raw bytes extracted from a file do the following:

CobValue::try_parse(CobFill::default(), Span::new_extra(bytes, CobLocationMetadata { file: "your_file.rawcob" }))

The CobValue::extract method can be used to deserialize values into rust types.

Syntax highlighting is provided for the .rawcob file extension:

§bevy compatability

bevybevy_cobweb_ui
0.160.13.0 - main
0.150.5.0 - 0.12.3
0.140.1.0 - 0.4.1

Modules§

assets_ext
Contains various asset managers.
bevy_ext
builtin
cob
editoreditor
localization
Localization is the process of swapping out text, fonts, images, sounds, etc. based on the language preferences of a user.
prelude
react_ext
sickle
sickle_ext
This module provides COB instructions to control scene node attributes. For example, it allows you to animate the BackgroundColor of a UI node, or to provide a different Width if a node is Selected vs not selected, or allow TextLineColor to change when a text node’s parent is hovered.
tools
ui_bevy
This module provides extensions to bevy_ui that are compatible with COB files and the cobweb animation framework.

Macros§

load_embedded_scene_file
Loads an embedded widget.
write_text
Helper for writing text with a TextEditor.
write_text_span
Helper for writing text to a text span with a TextEditor.