Skip to content

The spawn function

spawn() in ue_spawn.py spawns something from a file name or a keyword. It guesses the type from the extension or the word, and returns the Unreal actor.

from ue_spawn import spawn
from unreal_engine import FVector, FRotator

spawn('cube', location=FVector(0, 0, 100))
spawn('C:/photos/sunset.jpg', location=FVector(300, 0, 200))

location, rotation and scale are Unreal values: FVector in centimetres with z up, and FRotator(roll, pitch, yaw). For metres and y up, use Entity, which calls spawn for you.

What it understands

You pass Type Notes
.png .jpg .tga .exr .webp .gif .psd ... image Other formats are converted to PNG. Keeps the aspect ratio.
.mp4 .avi .mov .mkv .webm ... video Converted to MP4 with ffmpeg if needed.
.wav .mp3 .ogg .flac or a sound asset sound Plays at once, or as_sound_actor=True for a clickable sphere.
.fbx .obj .glb .gltf .dae .ply .stl .blend .3ds ... 3D model
'cube' 'sphere' 'cylinder' 'cone' 'plane' primitive
'camera' 'cam' 'cine' camera A CineCameraActor that becomes your view
'camera_pawn' 'flycam' camera pawn A camera you can fly
'earth' 'globe' 'cesium' earth Cesium globe
'table' or .zarr table See Tables
'plot' 'surface' 'heatmap' 'graph' plot See Plots
'latex' 'formula' 'equation' LaTeX See LaTeX
'text3d' 'cell' 3D text cell text='...'
'gizmo' transform gizmo
'file_explorer' 'files' file explorer
'shell' 'terminal' shell cell
'sysmon' 'monitor' system monitor
'desktop' your desktop icons
'pyactor' a PyActor needs python_module= and python_class=
'/Game/...' Blueprint or asset

If it can't tell, pass type=:

spawn('/Game/Sounds/Explosion', type='sound')

Examples

spawn('C:/photos/sunset.jpg', location=FVector(0, 0, 100))

actor, player, texture = spawn('C:/videos/clip.mp4', location=FVector(400, 0, 100))
player.call('Pause')
player.call('Play')
spawn('C:/models/chair.glb', location=FVector(0, 0, 0))
spawn('C:/models/scene.blend')          # converted with Blender

# Load a glTF at runtime without importing it
import os, unreal_engine as ue
from ue_spawn import spawn_gltf_runtime
spawn_gltf_runtime(os.path.join(ue.get_content_dir(), 'Models', 'Duck.glb'),
                   location=FVector(0, 0, 100))
spawn('cylinder', scale=FVector(0.5, 0.5, 3.0), location=FVector(0, 300, 0))
spawn('C:/music/song.mp3', volume=0.5)
spawn('/Game/Sounds/Ambient', type='sound', as_sound_actor=True,
      location=FVector(500, 0, 50))
spawn('camera', camera_preset='bokeh_portrait', location=FVector(-500, 0, 200))
spawn('camera', camera_preset='bokeh_macro', aperture=0.7, focus_distance=80.0)
spawn('camera', camera_preset='panini', location=FVector(0, 0, 100))
spawn('camera', camera_type='standard')

from ue_spawn import disable_panini
disable_panini()

Presets: default (35 mm f/5.6), cinematic (24 mm f/2.8), bokeh_portrait (85 mm f/1.4), bokeh_telephoto (135 mm f/1.8), bokeh_macro (50 mm f/0.95), panini (14 mm with Panini projection), cctv (6 mm), anamorphic (40 mm f/2.0).

spawn('earth')                              # satellite
spawn('earth', earth_preset='night')        # 'satellite_labels', 'map', 'night'
spawn('earth', earth_asset_id=2)            # any Cesium Ion asset id
spawn('/Game/Blueprints/BP_Cell', location=FVector(300, 0, 0))

The spawn_* functions

spawn() calls one of these. Call them yourself for options spawn() doesn't pass on.

Function Spawns
spawn_primitive(type, location, rotation, scale) A shape
spawn_image(path, ...), spawn_video(path, ...) A picture or video plane
spawn_sound(path, location, volume, pitch, ...) A sound
spawn_obj(path, ...), spawn_gltf_runtime(path, ...) A 3D model
spawn_camera(...), spawn_camera_pawn(...) Cameras
spawn_earth(preset=...) Cesium Earth
spawn_text3d(text, ...) 3D text
spawn_text3d_executor(text, ...) A code cell
spawn_table(table, ...), spawn_table_actor(table, ...) Tables
spawn_plot(function_expr, ...), spawn_zoom_plot(...) Plots
spawn_manim(scene, ...) Manim
spawn_latex(source, ...) LaTeX
spawn_gizmo(...) Transform gizmo
spawn_icon(pil_image, ...), spawn_icon_from_path(path, ...) Clickable icons
spawn_file_explorer(...), spawn_desktop_icons(...), spawn_system_monitor(...) Desktop tools
spawn_blueprint(bp_path, ...), spawn_class(uclass, ...) Any Blueprint or class
spawn_pyactor(module, class, ...) A PyActor

spawn_pyactor

spawn_pyactor spawns an actor that runs one of your Python classes:

from ue_spawn import spawn_pyactor
from unreal_engine import FVector

actor = spawn_pyactor(
    'my_module', 'Spinner',
    location=FVector(0, 0, 200),
    components=[{'class_name': 'StaticMeshComponent', 'name': 'Mesh',
                 'mesh': '/Engine/BasicShapes/Cube.Cube', 'root': True}],
)
actor.get_py_proxy()     # your Spinner instance
Content/Scripts/my_module.py
class Spinner:
    def begin_play(self):
        self.speed = 90          # degrees a second

    def tick(self, delta_time):
        rot = self.uobject.get_actor_rotation()
        rot.yaw += self.speed * delta_time
        self.uobject.set_actor_rotation(rot)

Components are added after begin_play, so use them from the first tick on.

In the tests

These are the functions test_spawn.py runs, copied from the code when this site is built. Each one is a complete, working use of a spawn function. base_y is where along Y the test puts its actors; see Tests as examples.

From the tests: test_primitives (Content/Scripts/test_spawn.py:486)
def test_primitives(base_y=0):
    """Spawn all 5 primitive shapes along Y, starting at *base_y*."""
    from ue_spawn import spawn_primitive
    results = {}
    shapes = ['cube', 'sphere', 'cylinder', 'cone', 'plane']
    for i, shape in enumerate(shapes):
        loc = FVector(0, base_y + i * 200, 100)
        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_primitive(shape, location=loc)
        except Exception as e:
            _log_exception(f'primitive_{shape}', e)
        elapsed = time.monotonic() - t0
        results.update(_result(f'primitive_{shape}', actor, elapsed=elapsed))
    return results

View it on GitHub

From the tests: test_image (Content/Scripts/test_spawn.py:504)
def test_image(base_y=0):
    """
    Spawn from a test image and verify cube matches image pixel dimensions.
    Lays out two spawns at base_y and base_y+400 along Y.

    Priority order for the test image:
      1. User-specified Feedback Hub screenshot
         (C:\\Users\\...\\WindowsFeedbackHub\\LocalState\\{...}\\Capture0.png)
      2. Any PNG on the Desktop
      3. Freshly created 320×180 (16:9) PIL image so the non-uniform
         scale is visually obvious.
    """
    from ue_spawn import spawn_image
    results = {}

    # 1. find an image path
    img_path = None

    # (a) User-specified Feedback Hub screenshot
    fb_root = os.path.expandvars(
        r'%LOCALAPPDATA%\Packages\Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe'
        r'\LocalState')
    if os.path.isdir(fb_root):
        try:
            for sub in os.listdir(fb_root):
                cand = os.path.join(fb_root, sub, 'Capture0.png')
                if os.path.exists(cand):
                    img_path = cand
                    _log(f'  image_valid: using Feedback Hub screenshot {cand}')
                    break
        except Exception:
            pass

    # (b) Any PNG on the Desktop
    if img_path is None:
        try:
            for f in os.listdir(DESKTOP):
                if f.lower().endswith('.png') and not f.startswith('_test_spawn'):
                    img_path = os.path.join(DESKTOP, f)
                    _log(f'  image_valid: using Desktop PNG {img_path}')
                    break
        except Exception:
            pass

    # (c) Generate a 320x180 (16:9) test image so the rectangle shape is
    #     obvious if the scaling works.
    if img_path is None:
        img_path = os.path.join(DESKTOP, '_test_spawn_img.png')
        try:
            from PIL import Image as PILImage, ImageDraw
            img = PILImage.new('RGB', (320, 180), color=(30, 30, 30))
            d = ImageDraw.Draw(img)
            # red border so we can see the aspect ratio instantly in-world
            d.rectangle([0, 0, 319, 179],      outline=(255, 0, 0), width=6)
            d.rectangle([20, 20, 299, 159],    outline=(0, 255, 0), width=3)
            d.line([(0, 0), (319, 179)],       fill=(0, 180, 255), width=2)
            d.line([(0, 179), (319, 0)],       fill=(0, 180, 255), width=2)
            img.save(img_path)
            _log(f'  image_valid: generated 320x180 test image {img_path}')
        except Exception as e:
            results.update(_skip('image_valid', f'PIL unavailable: {e}'))
            img_path = None

    # 2. log expected cube dimensions
    if img_path and os.path.exists(img_path):
        try:
            from PIL import Image as PILImage
            with PILImage.open(img_path) as probe:
                pw, ph = probe.width, probe.height
            # spawn_image default scale: FVector(w/100, 0.05, h/100)
            # cube is 100 UU per side, so final size = (w, 5, h) UU
            _log(f'  image_valid: src pixels = {pw}×{ph}  '
                 f'→ expected world = {pw}×5×{ph} UU  '
                 f'(scale={pw/100:.2f}, 0.05, {ph/100:.2f})')
        except Exception as e:
            _log(f'  image_valid: could not probe size: {e}')

        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_image(img_path, location=FVector(0, base_y, 100))
            if actor is not None:
                # Verify the scale UE actually applied
                try:
                    s = actor.get_actor_scale()
                    _log(f'  image_valid: actor scale = '
                         f'({s.x:.3f}, {s.y:.3f}, {s.z:.3f})')
                except Exception as e:
                    _log(f'  image_valid: could not read actor scale: {e}')
        except Exception as e:
            _log_exception('image_valid', e)
        results.update(_result('image_valid', actor,
                               elapsed=time.monotonic() - t0))

    # 3. invalid path — None is the correct result
    bad = None
    t0 = time.monotonic()
    try:
        bad = spawn_image('C:/nonexistent_path/bad.png',
                          location=FVector(0, base_y + 400, 100))
    except Exception:
        pass
    elapsed = time.monotonic() - t0
    results['image_invalid_path'] = {'ok': bad is None, 'actor': bad,
                                     'elapsed': elapsed}
    _log(f'  elapsed: {elapsed:.3f}s')
    _log(f'[{"PASS" if bad is None else "FAIL"}] image_invalid_path')
    return results

View it on GitHub

From the tests: test_video (Content/Scripts/test_spawn.py:614)
def test_video(base_y=0):
    """
    Spawn the loading_screen.mp4 as a vertical picture-frame video plane
    using MP_VideoTexture_Video_Mat, plus run the legacy Desktop-MP4 scan.
    """
    from ue_spawn import spawn_video
    results = {}

    # video cube: plays loading_screen.mp4 via MediaPlayer
    loading_mp4 = (r'C:\Users\nicho\Documents\Unreal Projects\Starcel9\Content\Movies\loading_screen.mp4')
    if os.path.exists(loading_mp4):
        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_video(
                loading_mp4,
                location=FVector(0, base_y + 400, 100),
            )
        except Exception as e:
            _log_exception('video_cube', e)
        results.update(_result('video_cube', actor,
                               extra='cube playing loading_screen.mp4',
                               elapsed=time.monotonic() - t0))
    else:
        results.update(_skip('video_cube', f'not found: {loading_mp4}'))

    return results

View it on GitHub

From the tests: test_sound (Content/Scripts/test_spawn.py:643)
def test_sound(base_y=0):
    """Exercise ue_spawn.spawn_sound with a filesystem audio file, in both
    world-playback and actor-hosted modes."""
    from ue_spawn import spawn_sound
    results = {}

    if os.path.isfile(_BIG_BAD_JOHN_FLAC):
        sw = None
        t0 = time.monotonic()
        try:
            sw = spawn_sound(_BIG_BAD_JOHN_FLAC,
                             location=FVector(0, base_y, 100))
        except Exception as e:
            _log_exception('sound_file_flac', e)
        results.update(_result('sound_file_flac', sw,
                               inputs={'path': _BIG_BAD_JOHN_FLAC},
                               extra='decoded via ffmpeg -> SoundWaveProcedural',
                               elapsed=time.monotonic() - t0))

        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_sound(_BIG_BAD_JOHN_FLAC,
                                location=FVector(0, base_y + 200, 100),
                                as_actor=True)
        except Exception as e:
            _log_exception('sound_file_flac_as_actor', e)
        results.update(_result('sound_file_flac_as_actor', actor,
                               inputs={'path': _BIG_BAD_JOHN_FLAC,
                                       'as_actor': True},
                               extra='click sphere to play (SoundSphere host)',
                               elapsed=time.monotonic() - t0))
    else:
        results.update(_skip('sound_file_flac',
                             f'not found: {_BIG_BAD_JOHN_FLAC}'))
        results.update(_skip('sound_file_flac_as_actor',
                             f'not found: {_BIG_BAD_JOHN_FLAC}'))
    return results

View it on GitHub

From the tests: test_cameras (Content/Scripts/test_spawn.py:683)
def test_cameras(base_y=0):
    """Spawn each camera preset along Y. Click a cube to replace the drone's
    first-person camera with it (you keep flying the drone); click the same
    one again to get the drone's own camera back."""
    from ue_spawn import spawn_camera_actor, CAMERA_PRESETS
    results = {}
    for i, preset_name in enumerate(CAMERA_PRESETS):
        loc = FVector(0, base_y + i * 500, 300)
        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_camera_actor(location=loc, camera_type=preset_name)
        except Exception as e:
            _log_exception(f'camera_{preset_name}', e)
        results.update(_result(f'camera_{preset_name}', actor,
                               elapsed=time.monotonic() - t0))
    return results

View it on GitHub

From the tests: test_earth (Content/Scripts/test_spawn.py:702)
def test_earth(base_y=0):
    """Spawn Cesium Earth with satellite and night presets."""
    from ue_spawn import spawn_earth
    results = {}
    for i, preset in enumerate(['satellite', 'night']):
        loc = FVector(0, base_y + i * 500, 0)
        actor = None
        t0 = time.monotonic()
        try:
            actor = spawn_earth(location=loc, preset=preset,
                                scale=FVector(0.00001, 0.00001, 0.00001))
        except Exception as e:
            _log_exception(f'earth_{preset}', e)
        results.update(_result(f'earth_{preset}', actor,
                               elapsed=time.monotonic() - t0))
    return results

View it on GitHub

From the tests: test_3d_object (Content/Scripts/test_spawn.py:1215)
def test_3d_object(base_y=0):
    """Spawn Content/Models/Duck.glb dynamically via the GLTFImporter plugin.

    Pipeline:
      1. ue.load_object('/Game/Models/Duck') if already imported.
      2. Otherwise: GLTFImportFactory + AssetImportTask(bAutomated=True) →
         factory_import_object — bypasses the modal options dialog that
         AssetTools.ImportAssets would otherwise show.
      3. world.actor_spawn(StaticMeshActor) + Mobility=Movable BEFORE
         SetStaticMesh (see feedback_movable_mobility memory).
    """
    from unreal_engine.classes import StaticMesh, StaticMeshActor
    from unreal_engine.enums import EComponentMobility

    if not os.path.isfile(_DUCK_GLB):
        return _skip('3d_object', f'not found: {_DUCK_GLB}')

    t0 = time.monotonic()
    dest_folder = '/Game/Models'
    # GLTFImportFactory writes the mesh under /Game/Models/Duck/<glTF mesh name>.
    # For Duck.glb the mesh name is "LOD3spShape" (prefixed "0_" by the factory).
    # Probe that path FIRST so re-runs hit the cached .uasset and skip the
    # 5-second distance-field rebuild that re-import triggers — and the
    # bare /Game/Models/Duck paths (which always miss for this glTF) never
    # get reached, eliminating their LogLinker miss warnings on every run.
    asset_candidates = [
        '/Game/Models/Duck/0_LOD3spShape',
        '/Game/Models/Duck',
        '/Game/Models/Duck/Duck',
    ]

    def _load_first():
        for p in asset_candidates:
            try:
                obj = ue.load_object(StaticMesh, p)
                if obj is not None:
                    return obj
            except Exception:
                continue
        return None

    def _scan_dest_for_static_mesh():
        """Scan dest_folder via AssetRegistry for any StaticMesh — used after
        factory_import_object returns the outer rather than the mesh itself."""
        try:
            from unreal_engine.classes import AssetRegistryHelpers
            registry = AssetRegistryHelpers.GetAssetRegistry()
        except Exception:
            return None
        assets = None
        for method in ('get_assets_by_path', 'GetAssetsByPath'):
            fn = getattr(registry, method, None)
            if fn is None:
                continue
            try:
                assets = fn(dest_folder, True)
                break
            except Exception:
                continue
        if not assets:
            return None
        for data in assets:
            try:
                loaded = data.get_asset() if hasattr(data, 'get_asset') else None
                if loaded is not None and _is_static_mesh(loaded):
                    return loaded
            except Exception:
                continue
        return None

    def _is_static_mesh(obj):
        try:
            return obj is not None and obj.get_class().get_name() == 'StaticMesh'
        except Exception:
            return False

    # Step 1: load if already imported.
    mesh = _load_first()

    # Step 2: import via UGLTFImportFactory with bAutomated=True so the
    # plugin's options dialog is skipped (see header comment).
    if mesh is None:
        try:
            factory_class = ue.find_class('GLTFImportFactory')
            task_class = ue.find_class('AssetImportTask')
            if factory_class is None or task_class is None:
                raise Exception(
                    'GLTFImportFactory / AssetImportTask class not found — '
                    'is the GLTFImporter plugin enabled in Starcel9.uproject?')
            factory = ue.new_object(factory_class)
            task = ue.new_object(task_class)
            task.bAutomated = True
            task.bReplaceExisting = True
            task.bSave = False
            task.Filename = _DUCK_GLB
            task.DestinationPath = dest_folder
            factory.AssetImportTask = task
            asset = factory.factory_import_object(_DUCK_GLB, dest_folder)
            if _is_static_mesh(asset):
                mesh = asset
            else:
                # factory_import_object can return the package's outer for
                # multi-mesh glTF; fall back to canonical asset paths, then
                # scan the dest folder for any StaticMesh.
                mesh = _load_first() or _scan_dest_for_static_mesh()
        except Exception as e:
            _log_exception('3d_object/factory_import', e)
            mesh = _load_first() or _scan_dest_for_static_mesh()

    if mesh is None:
        return _result('3d_object', None,
                       inputs={'path': _DUCK_GLB, 'dest': dest_folder},
                       extra='import failed — is GLTFImporter plugin enabled?',
                       elapsed=time.monotonic() - t0)

    # Step 3: spawn StaticMeshActor.  Mobility must be Movable BEFORE
    # SetStaticMesh on respawn (project memory: feedback_movable_mobility).
    actor = None
    try:
        world = get_world()
        actor = world.actor_spawn(StaticMeshActor)
        smc = actor.StaticMeshComponent
        smc.Mobility = EComponentMobility.Movable
        smc.SetStaticMesh(mesh)
        actor.set_actor_location(FVector(0, base_y, 100))
        actor.set_actor_scale(FVector(0.01, 0.01, 0.01))
    except Exception as e:
        _log_exception('3d_object/spawn', e)

    return _result('3d_object', actor,
                   inputs={'path': _DUCK_GLB, 'dest': dest_folder},
                   extra=f'mesh={mesh.get_name()} via GLTFImporter',
                   elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_glb_object_runtime (Content/Scripts/test_spawn.py:1362)
def test_glb_object_runtime(base_y=0):
    """Spawn Content/Models/Duck.glb at runtime via the glTFRuntime plugin.

    Side-by-side with test_3d_object so the duck shows up twice in the same
    suite — easy visual confirmation that both pipelines work and produce a
    matching mesh. The glTFRuntime version is the only one that survives in
    a packaged build (editor importers are stripped).
    """
    from ue_spawn import spawn_gltf_runtime

    if not os.path.isfile(_DUCK_GLB):
        return _skip('glb_object_runtime', f'not found: {_DUCK_GLB}')
    if ue.find_class('glTFRuntimeAssetActor') is None:
        return _skip(
            'glb_object_runtime',
            'glTFRuntime plugin not loaded — enable in Starcel9.uproject + rebuild')

    t0 = time.monotonic()
    actor = None
    try:
        actor = spawn_gltf_runtime(
            _DUCK_GLB,
            location=FVector(0, base_y, 100),
            scale=FVector(0.1, 0.1, 0.1))
    except Exception as e:
        _log_exception('glb_object_runtime/spawn', e)

    return _result('glb_object_runtime', actor,
                   inputs={'path': _DUCK_GLB, 'spawner': 'spawn_gltf_runtime'},
                   extra='via glTFRuntime plugin (runtime parse, no .uasset)',
                   elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_text3d_executor (Content/Scripts/test_spawn.py:1395)
def test_text3d_executor(base_y=0):
    """Spawn a Ctrl+Enter Python executor Text3D.

    Exercises ue_spawn.spawn_text3d_executor — the convenience wrapper
    around spawn_text3d_pyactor that hardcodes the
    pyactor_text3d_executor.PyActorText3DExecutor proxy.

    Click the spawned text to focus it (requires test_text3d_click typing
    setup), edit the code, then press Ctrl+Enter to exec(). The default
    payload is a one-line ue.log call so a smoke test is visible in the
    Output Log.
    """
    from ue_spawn import spawn_text3d_executor
    actor = None
    t0 = time.monotonic()
    try:
        actor = spawn_text3d_executor(
            text='ue.log("hello from Ctrl+Enter")',
            location=FVector(0, base_y, 200),
        )
    except Exception as e:
        _log_exception('text3d_executor', e)

    child = None
    try:
        child = getattr(actor, 'text3d_actor', None) if actor else None
    except Exception:
        pass
    extra = (f'child={child.get_name()} (Ctrl+Enter to run)'
             if child else 'no child attached')
    return _result('text3d_executor', actor, extra=extra,
                   elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_gizmo (Content/Scripts/test_spawn.py:1429)
def test_gizmo(uobject=None, input_manager=None, location=None, base_y=0):
    """
    Spawn the interactive transform gizmo (target cylinder + move arrows,
    rotate rings, scale handles, plane squares) and wire up drag interaction.
    Returns (target, handles, pyactor).

    Delegates to ue_spawn.spawn_gizmo so the GizmoController is hosted on a
    BP_PyActorEmpty (the canonical spawn_pyactor default). Omitting uobject
    /input_manager spawns the gizmo statically (no drag / no PyActor).
    """
    from ue_spawn import spawn_gizmo

    if location is None:
        # Z=250 keeps the scale handles (which extend ±175 UU around the
        # target) from sitting underground.
        location = FVector(0, base_y, 250)

    _log('--- test_gizmo ---')
    _log(f'Spawning gizmo target at {location}')

    t0 = time.monotonic()
    try:
        target, handles, pyactor = spawn_gizmo(
            location=location,
            uobject=uobject,
            input_manager=input_manager,
        )
    except Exception as e:
        _log(f'test_gizmo: spawn failed: {e}')
        _result('gizmo', None, extra=str(e),
                elapsed=time.monotonic() - t0)
        return None, None, None

    if handles is not None:
        _log(f'test_gizmo: spawned target + {len(handles)} handles')

    if uobject is not None and input_manager is not None:
        if pyactor is not None:
            _log('test_gizmo: GizmoController PyActor spawned + wired '
                 '(drag LMB on any handle)')
        else:
            _log('test_gizmo: GizmoController setup failed')
    else:
        _log('test_gizmo: WARNING — no uobject/input_manager; '
             'gizmo will be static (no drag). Pass self.uobject and '
             'self.input from Main.begin_play to enable interaction.')

    _result('gizmo', target,
            extra=f'{len(handles) if handles else 0} handles',
            elapsed=time.monotonic() - t0)
    return target, handles, pyactor

View it on GitHub

From the tests: test_icon (Content/Scripts/test_spawn.py:952)
def test_icon(base_y=0):
    """Spawn a BP_Icon from a plain PIL image."""
    from ue_spawn import spawn_icon
    actor = None
    t0 = time.monotonic()
    try:
        from PIL import Image as PILImage
        img = PILImage.new('RGBA', (256, 256), (0, 200, 50, 255))
        actor = spawn_icon(img, location=FVector(0, base_y, 100))
        if actor:
            try:
                actor.get_actor_component('Sphere').SetSimulatePhysics(True)
            except Exception as phys_e:
                _log(f'  icon physics: {phys_e}')
    except Exception as e:
        _log_exception('icon_from_pil', e)
    return _result('icon_from_pil', actor, elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_desktop_icons (Content/Scripts/test_spawn.py:845)
def test_desktop_icons(base_y=0):
    """Spawn first 5 desktop shell icons as BP_Icon actors."""
    from ue_spawn import spawn_desktop_icons
    actors = []
    t0 = time.monotonic()
    try:
        actors = spawn_desktop_icons(
            location=FVector(0, base_y, 100),
            max_icons=5,
        )
    except Exception as e:
        _log_exception('desktop_icons', e)

    first = actors[0] if actors else None
    return _result('desktop_icons', first, extra=f'{len(actors)} spawned',
                   elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_file_explorer (Content/Scripts/test_spawn.py:995)
def test_file_explorer(base_y=0):
    """Spawn a FileExplorer PyActor populated via EverythingAPI.

    Spawned at Z=1500 because the wall_table renderer steps each row down
    in -Z; in practice Everything returns ~5-10 files for the default folder
    (~1200 UU tall), so the table sits comfortably above ground. With the
    full MAX_FILES=20 the lowest rows can clip the floor — acceptable
    tradeoff for keeping the visible top close to other tests' altitude.

    Requires Everything (Voidtools) running and Everything64.dll reachable.
    PASS = PyActor spawned; table + icons are rendered asynchronously in
    the component's begin_play and logged to UE output."""
    from ue_spawn import spawn_file_explorer
    actor = None
    t0 = time.monotonic()
    try:
        actor = spawn_file_explorer(
            location=FVector(0, base_y, 1500),
            initial_path=os.path.dirname(
                os.path.abspath(ue.get_content_dir())))
    except Exception as e:
        _log_exception('file_explorer', e)
    return _result('file_explorer', actor,
                   extra='needs Everything daemon + Everything64.dll',
                   elapsed=time.monotonic() - t0)

View it on GitHub

From the tests: test_system_monitor (Content/Scripts/test_spawn.py:720)
def test_system_monitor(base_y=0):
    """Spawn a PyActorSysmon dynamically (no Blueprint placeholder).

    Spawned at Z=2500 because the Text3D component renders multi-line stats
    output, with each new line stepping down in -Z; lower spawn heights
    left most rows near the floor or occluded by other test geometry.
    """
    from ue_spawn import spawn_system_monitor
    actor = None
    t0 = time.monotonic()
    try:
        actor = spawn_system_monitor(location=FVector(0, base_y, 2500))
    except Exception as e:
        _log_exception('system_monitor', e)
    return _result('system_monitor', actor, elapsed=time.monotonic() - t0)

View it on GitHub