UI

UiButton

Interactive UI button.

Button with base, hover, and pressed visual states.

Base node: UiBox

Source: perro_source/core/perro_ui/src/lib.rs

Fields

texthover_basepressed_baseclick_signalsenabled
pub struct UiButton {    pub base: UiBox,    pub hover_base: Option<UiBox>,    pub pressed_base: Option<UiBox>,    pub text: String,}

Scene template

[node_instance]tags = ["runtime", "demo"]parent = @rootscript = "res://script.rs"script_vars = { speed = 4.0, health = 100 }   [UiButton]    text = "Start"    hover_base = 0    pressed_base = 0    click_signals = []    enabled = true  [/UiButton][/node_instance]

Script API

Create

let node_id = create_node!(ctx, UiButton, "Spawned Node", ["enemy", "runtime"], parent_id);

Access / mutate

let value = with_node!(ctx, UiButton, node_id, |node| {    node.text}); let pair = with_node!(ctx, UiButton, node_id, |node| {    (node.text, node.hover_base)}); with_node_mut!(ctx, UiButton, node_id, |node| {    node.text = "Start".to_string();});