Files
VRyHungry1/UI/progress_bar_3d.gd
algodoogle 96ea2dd1ea mp fix
2026-07-28 19:41:31 +01:00

37 lines
939 B
GDScript

extends Node3D
class_name ProgressBar3D
@export var y_billboard: bool = false
@onready var progress_bar: ProgressBar = $Sprite3D/SubViewport/ProgressBar
@onready var sprite_3d: Sprite3D = $Sprite3D
func _ready() -> void:
if not progress_bar:
push_error("Progressbar3D missing reference to ProgressBar")
if y_billboard:
$Sprite3D.billboard = BaseMaterial3D.BillboardMode.BILLBOARD_FIXED_Y
func set_progress(value: float) -> void:
progress_bar.value = clamp(value, 0.0, 1.0) * 100
func get_progress() -> float:
return progress_bar.value
func set_bar_visible(value: bool) -> void:
progress_bar.visible = value
func is_bar_visible() -> bool:
return progress_bar != null and progress_bar.visible
func override_fill_color(color: Color) -> void:
var style_box := StyleBoxFlat.new()
style_box.bg_color = color
# Override the 'fill' StyleBox on the ProgressBar
progress_bar.add_theme_stylebox_override("fill", style_box)