godot-psd-training/UI/psl/light_model.gd

33 lines
852 B
GDScript3
Raw Normal View History

extends VBoxContainer
enum LightType{
green,# 绿色按钮
red,#红色按钮
}
@export var lightType:LightType
@export var lightText:String
signal clickButtonSignal(openLight:bool,button)
func _ready() -> void:
$Light/MarginContainer/Label.text=lightText
if lightType ==LightType.green :
var icon = preload("res://Assets/psl/指示灯_绿.png")
var icon2 = preload("res://Assets/psl/指示灯亮_绿.png")
$Light/closeLight.set_texture(icon)
$Light/openLight.set_texture(icon2)
elif lightType ==LightType.red :
var icon = preload("res://Assets/psl/指示灯_红.png")
var icon2 = preload("res://Assets/psl/指示灯亮_红.png")
$Light/closeLight.set_texture(icon)
$Light/openLight.set_texture(icon2)
func openLight () -> void:
$Light/openLight.visible = true
func closeLight () -> void:
$Light/openLight.visible = false