Files
fps_project_1/scripts/texture_catcher.gd
2024-12-11 16:11:29 -06:00

23 lines
755 B
GDScript

@tool
extends Node3D
@onready var sub_viewport: SubViewport = $CAPTURE/SubViewport
@onready var snapshot_model: Node3D = $CAPTURE/SubViewport/snapshotModel
@export var take_snapshot : bool = false
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if take_snapshot:
var snapshot_name = snapshot_model.get_child(0).get_name()
await get_tree().create_timer(.5).timeout
var img = sub_viewport.get_viewport().get_texture().get_image()
var image_path = "assets/Textures/ObjectTextures/%s.png" % snapshot_name
img.save_png(image_path)
take_snapshot = false