Skip to content

Instantly share code, notes, and snippets.

@FilipSivak
Created January 19, 2022 22:24
Show Gist options
  • Select an option

  • Save FilipSivak/fbbc3c449e59d1bae1f3e5f361204cff to your computer and use it in GitHub Desktop.

Select an option

Save FilipSivak/fbbc3c449e59d1bae1f3e5f361204cff to your computer and use it in GitHub Desktop.

Revisions

  1. FilipSivak created this gist Jan 19, 2022.
    25 changes: 25 additions & 0 deletions struct_enum_unreal_engine_python.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    # Example by Filip Sivak, written for https://filipsivak.medium.com/
    import unreal

    @unreal.uenum()
    class MyPythonEnum(unreal.EnumBase):
    FIRST = unreal.uvalue(0)
    SECOND = unreal.uvalue(1)
    FOURTH = unreal.uvalue(3)

    @unreal.ustruct()
    class PythonUnrealStruct(unreal.StructBase):
    some_string = unreal.uproperty(str)
    some_number = unreal.uproperty(float)
    array_of_string = unreal.uproperty(unreal.Array(str))

    @unreal.uclass()
    class PythonTestClass(unreal.BlueprintFunctionLibrary):

    @unreal.ufunction(static = True, params = [int], ret = PythonUnrealStruct)
    def MyPythonFunction(integer_argument1):
    struct = PythonUnrealStruct()
    struct.some_string = "5"
    struct.some_number = integer_argument1 + 1
    struct.array_of_string = ["a", "b", "c"]
    return struct