Created
February 14, 2021 20:02
-
-
Save rondreas/d251aeee36ff1b371d747359433005e6 to your computer and use it in GitHub Desktop.
Python version of https://docs.unrealengine.com/en-US/ProductionPipelines/ScriptingAndAutomation/Blueprints/StartupObjects/index.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
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
Not really the forum for this, but try looking at scoped slow tasks