godot_experiments/station_info_panel/style1/site_panel.gd

35 lines
584 B
GDScript3
Raw Permalink Normal View History

2024-04-27 10:02:45 +08:00
@tool
2024-04-30 18:09:56 +08:00
extends Node3D
2024-04-27 10:02:45 +08:00
2024-04-30 18:09:56 +08:00
## 面板宽度,单位(m)
@export_range(1, 10) var panelWidth: float = 3:
2024-04-27 10:02:45 +08:00
get:
2024-04-30 18:09:56 +08:00
return panelWidth
2024-04-27 10:02:45 +08:00
set(v):
2024-04-30 18:09:56 +08:00
panelWidth = v
2024-04-27 10:02:45 +08:00
update()
2024-04-30 18:09:56 +08:00
## 面板高度,单位(m)
@export_range(0.1, 5) var panelHeight: float = 1:
2024-04-27 10:02:45 +08:00
get:
2024-04-30 18:09:56 +08:00
return panelHeight
2024-04-27 10:02:45 +08:00
set(v):
2024-04-30 18:09:56 +08:00
panelHeight = v
2024-04-27 10:02:45 +08:00
update()
2024-04-30 18:09:56 +08:00
var isReady: bool
2024-04-27 10:02:45 +08:00
func update():
if not isReady:
return
2024-04-30 18:09:56 +08:00
var vp = $SubViewport
2024-04-27 10:02:45 +08:00
2024-04-30 18:09:56 +08:00
$Plane.mesh.size.x = panelWidth
$Plane.mesh.size.y = panelHeight
$Plane.material_override.albedo_texture = vp.get_texture()
2024-04-27 10:02:45 +08:00
func _ready():
isReady = true
2024-04-30 18:09:56 +08:00
print("csPanel ready")
2024-04-27 10:02:45 +08:00
update()