Python API/highrescreenshot


import unreal
import time

class OnTick(object):
  """ Register a function and run it on tick, """
  def __init__(self):
    # make a generator function so we can call next on it,
    self.actors = (actor for actor in unreal.EditorLevelLibrary.get_selected_level_actors())

    # register a callback on tick
    self.on_tick = unreal.register_slate_post_tick_callback(self.__tick__)

  def __tick__(self, deltatime):
    """ Function we will call every tick, """
    try:
      print(deltatime) # Print the deltatime just for sanity check so we
      # know a tick was made,

      # Get the next actor from our generator function,
      actor = next(self.actors)
      actor_location = actor.get_actor_location()

      # Solve the camera position, and rotation
      position = actor_location + unreal.Vector(200.0, 200.0, 200.0)

      # roll, pitch, yaw
      rotation = unreal.Rotator(0.0, -45.0, -130.0)

      unreal.EditorLevelLibrary.set_level_viewport_camera_info(
        position,
        rotation
      )

      # Take the screenshot,
      unreal.AutomationLibrary.take_high_res_screenshot(
        1920,
        1080,
        actor.get_name() + ".png"
      )

    except Exception as error:
      print(error)
      unreal.unregister_slate_post_tick_callback(self.on_tick)

if __name__ == '__main__':
  instance = OnTick()

Seeing people using it to hook up Qt event to it https://github.com/techartorg/TAO-Wi…ndow-BaseClass I based this example from that.