import unreal
import codecs
import os
def my_makedirs(path):
if not os.path.isdir(path):
os.makedirs(path)
my_makedirs(SaveDir)
print("SaveDir= "+SaveDir)
print("FileName= "+FileName)
savePath=SaveDir+"/"+FileName+".tga"
print("savePath= "+savePath)
editorAssetLib = unreal.EditorAssetLibrary()
texture2d=editorAssetLib.load_asset(assetPath)
#canvasRenderTarget2D=editorAssetLib.load_asset(assetPath)
#texture2d=unreal.Texture2D(canvasRenderTarget2D)
print("texture2d= "+str(texture2d))
task = unreal.AssetExportTask()
task.set_editor_property('automated', True)
task.set_editor_property('filename', savePath)
task.set_editor_property('object', texture2d)
task.set_editor_property('prompt', False)
task.set_editor_property('exporter', unreal.TextureExporterTGA())
check = unreal.Exporter.run_asset_export_task(task)
if check==True:
pass
else:
print(u"tga イメージの生成に失敗しました")