How to wait for take_high_res_screenshot?

I have a script that takes a screenshot using

screenshotTask = unreal.AutomationLibrary.take_high_res_screenshot(SCREEN_X, SCREEN_Y, screenshotPath)

How do I wait for screenshotTask.is_task_done() to become true?

1 Like

Think the file should be accessible the very next line, the limitation I found is mostly that you can only make one capture this frame. We implemented something like a ‘coroutine’ in our python bridge a function that would allow us to in python yield result per frame,

for x in range(10):
  # capture screen, and edit settings for next frame, 
  yield WaitForNextFrame

I noticed that on_tick waits for texture streaming causing hiccups and skips a few screenshots, but pre_tick does the work here is updated version

import unreal

class capture(object):
  def __init__(self):
    self.actors = (actor for actor in unreal.EditorLevelLibrary.get_selected_level_actors())
    self.on_pre_tick = unreal.register_slate_pre_tick_callback(self.__pretick__)

  def __pretick__(self, deltatime):
      actor = next(self.preactors)
      shot_name = actor.get_name()
      unreal.AutomationLibrary.take_high_res_screenshot(1920,1080, shot_name + ".png")
    except Exception as error:

What do you mean by “WaitForNextFrame”, is it a specific function that you use?

How can we take depth screenshot with python api’s???

what is the difference between 2 API’s

  1. unreal.AutomationLibrary.take_high_res_screenshot
  2. unreal.AutomationLibrary.take_automation_screenshot_at_camera

Can we have python script to take depth screenshot?

You could use a post process material for the render, SceneTexture has SceneDepth and CustomDepth and guess all GBuffers ( if you are working with deferred and not forward )