20tab / UnrealEnginePython

Embed Python in Unreal Engine 4
MIT License
2.76k stars 750 forks source link

Possible to chain commandlets? #444

Closed Schizo closed 5 years ago

Schizo commented 6 years ago

This is a more Unreal question but I thought, that we eventually could leverage other commandlets with PyCommandlet. Before going into details, I couldn't find any information if Unreal supports multiple commandlets.

This is a simple example that was provided in one of the threads, that' I've modified.

runner:

import subprocess

ue_editor = "E:/Program Files/Epic Games/UE_4.19/Engine/Binaries/Win64/UE4Editor-Cmd.exe"
project = "D:/projects/testExample.uproject"
command = "D:/Projects/test/job.py"
process = subprocess.Popen('{0} {1} -run=PyCommandlet {2}'.format(ue_editor, project, command))

job.py:

import unreal_engine as ue
open("E:/test7.txt", 'w').write(str(material))

I was excited as I thought, that we could add ue.editor_command_build_lighting() in job.py to actually force a render. However this seems to be skipped as not all modules are loaded.

Just for completeness, I'm adding the actual commandlet that is used to do lightbuilds:

    process = subprocess.Popen('{0} {1}  -run=resavepackages -buildlighting -allowcommandletrendering'.format(ue_editor, project, command))
rdeioris commented 6 years ago

Hi, you need to add -allowcommandletrendering to the pycommandlet command line too (this will setup RHI). Regarding multiple commandlets, i think there is no need for it. Just create an additional py script that calls the commandlets in chain