mirror of
https://github.com/Rundll86/Dog-Lynx-And-HCN.git
synced 2026-07-05 01:32:13 +08:00
fix(SkillIcon): 修复技能图标冷却进度显示问题
调整ShaderMaterial的默认progress值为0.5以匹配实际冷却状态 在_ready中复制材质实例避免共享材质引用 分离progress计算逻辑提高可读性
This commit is contained in:
@@ -17,7 +17,7 @@ corner_radius_bottom_left = 15
|
|||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ew32n"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ew32n"]
|
||||||
shader = ExtResource("1_jaivk")
|
shader = ExtResource("1_jaivk")
|
||||||
shader_parameter/progress = 0.25
|
shader_parameter/progress = 0.5
|
||||||
shader_parameter/backAlpha = 0.25
|
shader_parameter/backAlpha = 0.25
|
||||||
|
|
||||||
[node name="SkillIconBase" type="PanelContainer"]
|
[node name="SkillIconBase" type="PanelContainer"]
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ class_name SkillIcon
|
|||||||
|
|
||||||
@export var weapon: Weapon = null;
|
@export var weapon: Weapon = null;
|
||||||
|
|
||||||
@onready var textureRect = $"%texture"
|
@onready var textureRect: TextureRect = $"%texture"
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
textureRect.material = textureRect.material.duplicate()
|
||||||
func _physics_process(_delta):
|
func _physics_process(_delta):
|
||||||
if is_instance_valid(weapon):
|
if is_instance_valid(weapon):
|
||||||
textureRect.texture = weapon.avatarTexture
|
textureRect.texture = weapon.avatarTexture
|
||||||
textureRect.material.set_shader_parameter("progress", clamp(weapon.cooldownTimer.timeSinceLastStart() / weapon.cooldownTimer.cooldown, 0, 1))
|
var progress = weapon.cooldownTimer.timeSinceLastStart() / weapon.cooldownTimer.cooldown
|
||||||
|
textureRect.material.set_shader_parameter("progress", clamp(progress, 0, 1))
|
||||||
|
|||||||
Reference in New Issue
Block a user