Material Box

Material Box

WEBデザイン & フリー素材

Godot - プログレスバーの角の丸みを解除する

Godot

プログレスバーの角の丸みを解除するGDScriptです。


プログレスバーのノードにデフォルトで設定されている角の丸みを解除して「0」にするにはget_theme_stylebox()でスタイルを取得してプロパティを変更します。

# 現在値のバー
var bar = get_theme_stylebox('fill')
bar.corner_radius_bottom_right = 0
bar.corner_radius_bottom_left = 0
bar.corner_radius_top_left = 0
bar.corner_radius_top_right = 0

# 角の丸み
var bg = get_theme_stylebox('background')
bg.corner_radius_bottom_right = 0
bg.corner_radius_bottom_left = 0
bg.corner_radius_top_left = 0
bg.corner_radius_top_right = 0

他のデフォルトで設定されているスタイルも全て解除されてしまいますが、add_theme_stylebox_override()で新しくスタイルを割り当てる事で角の丸みを解除する事も可能です。

# 現在値のバー
var bar = StyleBoxFlat.new()
add_theme_stylebox_override('fill', bar)

# 背景のバー
var bg = StyleBoxFlat.new()
add_theme_stylebox_override('background', bg)

4つの角の丸みを一括で変更する場合はset_corner_radius_all()が利用可能です。

# 現在値のバー
var bar = StyleBoxFlat.new()
bar.set_corner_radius_all(0)

# 背景のバー
var bg = StyleBoxFlat.new()
bg.set_corner_radius_all(0)

Godot

TitleGodot - プログレスバーの角の丸みを解除する

CategoryGodot

Created

Update

AuthorYousuke.U