Skip to content

Instantly share code, notes, and snippets.

@rondreas
Created February 14, 2021 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rondreas/d251aeee36ff1b371d747359433005e6 to your computer and use it in GitHub Desktop.
Save rondreas/d251aeee36ff1b371d747359433005e6 to your computer and use it in GitHub Desktop.
import unreal
@unreal.uclass()
class OnAssetPostImportAction(unreal.EditorUtilityObject):
@unreal.ufunction(override=True)
def run(self):
""" Add a callable static function to be called whenever an asset is
imported.
"""
# Get the Import Subsystem,
import_subsytem = unreal.get_editor_subsystem(unreal.ImportSubsystem)
# Add a callable to the OnAssetPostImport delegate,
import_subsytem.on_asset_post_import.add_callable(
OnAssetPostImportAction.log_import_name
)
@unreal.ufunction(static=True, params=[unreal.Factory, unreal.Object], meta=dict(BlueprintEvent=True))
def log_import_name(factory, created_object):
""" Static function that should print asset name whenever a new asset is
imported.
:param factory: the factory class used for import
:type factory: unreal.Factory
:param created_object: the imported asset,
:type created_object: unreal.Object
"""
print("Hello %s" % created_object.get_name())
def main():
# Execute the run function for our Editor Utility Object,
OnAssetPostImportAction().run()
if __name__ == '__main__':
main()
@RyanHz2
Copy link

RyanHz2 commented Jul 1, 2021

i know the scoped slow tasks, but i mean
like this forum "StartupObjects/index.html" what we talk ,
if it run ,it will run a long time to "print("Hello %s" % created_object.get_name())" when i import some assets
but with UE running, i want it stop, stop this code running, back to the time i can import assets without this code by my thought
it is the question i think a lot ,when i keep develop this forum.
Sorry to occupy your time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment