screen_capture.gd 335 B

12345678910111213
  1. extends Node
  2. @onready var captured_image = $CapturedImage
  3. func _on_CaptureButton_pressed():
  4. # Retrieve the captured image.
  5. var img = get_viewport().get_texture().get_image()
  6. # Create a texture for it.
  7. var tex = ImageTexture.create_from_image(img)
  8. # Set the texture to the captured image node.
  9. captured_image.set_texture(tex)