Announcement

Collapse
No announcement yet.

How to specify multiple output values in a Python-only ufunction?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Thank you very much for taking the time to reply Jamie Dale, much appreciated. I'll stick with single primitive return values for now.

    Leave a comment:


  • replied
    Yes, but the types are transient, so you don't want to use them for anything persistent (like an asset type, or a reference within a BP).

    Leave a comment:


  • replied
    Jamie Dale Does UE 4.24.1 support defining ustructs from python with its own set of properties? I'm hoping to achieve what was achieved using blueprint function libraries, but for my own structs that may be consumed by blueprint function libraries.

    Leave a comment:


  • replied
    The following also does not work (causing the editor to crash without warning when creating a data asset from PyYourDataAsset from the content browser).

    Code:
    @unreal.uclass()
    class PyYourDataAsset(unreal.DataAsset):
        """ A python-based data asset
    
        @var hello The hello
        """
    
        def __init__(self):
            self.hello = unreal.uproperty(str, meta=dict(EditAnywhere, BlueprintReadWrite, Category="PyYourDataAsset"), setter=_set_hello, getter=_get_hello)
            self._hello = "hello world"
    
        def _set_hello(self, new_hello):
            self._hello = new_hello
    
        def _get_hello(self):
            return self._hello

    Leave a comment:


  • replied
    This post describes how to create blueprint function libraries from Python: https://medium.com/@joe.j.graf/build...n-746ea9dd08b2

    In short, create YourPlugin/Content/Python/init_unreal.py and add the following code:

    Code:
    import unreal
    @unreal.uclass()
    class YourBPL(unreal.BlueprintFunctionLibrary):
        "" Your class documentation """
        @unreal.ufunction(ret=bool, params=[int], static=True, meta=dict(Category="YourBPL"))
        def YourFunction(your_param):
            "Your function documentation"
            return False
    How does one specify a ustruct with uproperties from Python? The following does not work.

    Code:
    import unreal
    @unreal.ustruct()
    class YourStruct:
        """ Your struct documentation """
    
        """ Your property documentation """
        @unreal.uproperty()
        some_string
    
        """ Your other property documentation """
        @unreal.uproperty()
        some_int
    If I can get that right, then I might be able to update my ufunction's ret value to 'ret=YourStruct'.

    Leave a comment:


  • replied
    Thanks, that sounds like a good alternative approach.

    Leave a comment:


  • replied
    you can use a ustruct to do that.

    Leave a comment:


  • How to specify multiple output values in a Python-only ufunction?

    I have a Python-based blueprint function library, and I am trying to find the right syntax for specifying multiple output values. If I specify ret=(int,int) in the ufunction declaration, then the generated blueprint node has two integer output values (named Out Value 1 and Out Value 2) as well as a boolean return value. Ideally I would like to be able to specify the names of the output values, and not have a boolean return value for the node.
Working...
X