Have any of you worked with automating import settings/asset setup in Unreal? I'm looking for something along the lines of what the AssetPostprocessor/AssetImporter API does in Unity

[quote]
View in #engine_unreal on Slack

johanna @johanna: Have any of you worked with automating import settings/asset setup in Unreal? I’m looking for something along the lines of what the AssetPostprocessor/AssetImporter API does in Unity, where I can customize automatic setup of imported assets based on naming, location or other. I’ve understood that there is no similar type of OnImport hook in Unreal, so how do you generally work with automating this part of the pipeline?

Stefan @Stefan: you can pre-determine what settings are set in the window that appears when you import something. That is the only way I figured out so far. Those can be found in .ini files.

bob.w @bob.w: There are some callback hooks in the code, but from what I remember (5 years ago, maybe (hopefully?) changed), but the issue I hit was that re-import would bypass them, and the re-import hook didn’t have a handle on the asset-factory so even when listening to it, I couldn’t reliably bash the process together in a way that felt stable and useful

deiss @deiss: We added code for the textureimporter to set proper groups and such, based on the name. If you look in the code, IRRC there is a place where Epic determines Normalmaps, where you could hook into…
the reimport issue Bob mentioned was not too much of an issue for us, where naming guidelines (and photoshop export rules/checks) were established…

bob.w @bob.w: Yeah, I was working with animclips and inserting footstep events (I think?) based on some data in the fbx files that worked fine until someone hit reimport and then it’d blow away my extra data. it was so close, and yet so far :slightly_smiling_face:

robberyman @robberyman: @johanna there are callbacks you can hook into using python and blueprints,

import unreal

@unreal.uclass()
class OnAssetImports(unreal.EditorUtilityObject):
    @unreal.ufunction(static=True, params=[unreal.Factory, unreal.Object], meta=dict(BlueprintEvent=True))
    def log_import_name(factory, created_object):
        print("Hello %s" % created_object.get_name())

import_subsytem = unreal.get_editor_subsystem(unreal.ImportSubsystem)

import_subsytem.on_asset_post_import.add_callable(
    OnAssetImports.log_import_name
)

print("Added my callback")

If you have them in your content/python/init_unreal.py they shouldn’t get chomped by the garbage collector, if you’re doing them as blueprints you can follow the docs on how to make startup … commands? or whatever they were called

bob.w @bob.w: I feel “old man yelling about new-fangled” things given that python didn’t exist last time I used unreal :smile:

robberyman @robberyman: We were pretty fast adding python as soon as epic even made it a beta feature (after convincing some very hesitant programmers) :stuck_out_tongue: after epics training vid where they stated anything blueprint can do, python can do as well I’ve attempted doing all kinds of things in python for unreal, think the most used was an impostor creator that took hires screenshots of actors with all the different buffers.

instinct-vfx @instinct-vfx: It’s great to have python, but it is also often frustrating. The whole “init_unreal.py” custom bootstrapping is such a stick between my legs. Also no runtime support is making me cry bitter tears
(Disclaimer: Not in games here)