Announcement

Collapse
No announcement yet.

List all editor properties

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

    List all editor properties

    Is there a way via the Python API to list all editor properties of a given object?

    I found this for UObjects in c++ but couldn't find a corresponding class or methodology in the Python docs:
    https://answers.unrealengine.com/que...a-uobject.html

    Without such a method there doesn't seem to be a good way to figure out what you can set via set_editor_property()

    #2
    Good morning,

    I did not find any possible way to do it in Python only, but here is the way I'm doing it using C++

    .h
    Code:
    #include "CoreMinimal.h"
    #include "Kismet/BlueprintFunctionLibrary.h"
    #include "CppLib.generated.h"
    UCLASS()
    class UNREALPYTHONPROJECT_API UCppLib : public UBlueprintFunctionLibrary {
        GENERATED_BODY()
    public:
        UFUNCTION(BlueprintCallable, Category = "Unreal Python")
            static TArray<FString> GetAllProperties(UClass* Class);
    };
    .cpp
    Code:
    #include "CppLib.h"
    #include "Runtime/CoreUObject/Public/UObject/UnrealType.h"
    TArray<FString> UCppLib::GetAllProperties(UClass* Class) {
        TArray<FString> Ret;
        if (Class != nullptr) {
            for (TFieldIterator<UProperty> It(Class); It; ++It) {
                UProperty* Property = *It;
                if (Property->HasAnyPropertyFlags(EPropertyFlags::CPF_Edit)) {
                    Ret.Add(Property->GetName());
                }
            }
        }
        return Ret;
    }
    And then in python:
    Code:
    import unreal
    my_python_object = unreal.StaticMesh()
    my_object_properties = unreal.CppLib.get_all_properties(my_python_object.get_class())
    print my_object_properties
    Have An Awesome And Productive Day
    Alex, Youtube Tutorials

    Comment


      #3
      Running into a trove of issues trying to recreate this, among them this.

      Code:
      ... 'UMyClass' uses undefined class 'UNREALPYTHONPROJECT_API'    ProjName    $ProjPath\MyClass.h    6
      Besides a barrage from Visual Studio complaining about Syntax error with missing ';' after UCLASS() etc...

      Had to alter the Atomic.h as well seeing it was complaining about a missing ')' and found others having same issue

      My full code is currently

      Code:
      #include "CoreMinimal.h"
      #include "Kismet/BlueprintFunctionLibrary.h"
      #include "MyClass.generated.h"
      
      UCLASS()
      class UNREALPYTHONPROJECT_API UMyClass : public UBlueprintFunctionLibrary {
          GENERATED_BODY()
      public:
          UFUNCTION(BlueprintCallable, Category = "Unreal Python")
          static TArray<FString> GetAllProperties(UClass* Class);
      };
      MyClass.h

      Code:
      #include "MyClass.h"
      #include "Runtime/CoreUObject/Public/UObject/UnrealType.h"
      
      TArray<FString> UMyClass::GetAllProperties(UClass* Class) {
          TArray<FString> Ret;
          if (Class != nullptr) {
              for (TFieldIterator<UProperty> It(Class); It; ++It) {
                  UProperty* Property = *It;
                  if (Property->HasAnyPropertyFlags(EPropertyFlags::CPF_Edit)) {
                      Ret.Add(Property->GetName());
                  }
              }
          }
          return Ret;
      }
      MyClass.cpp

      Any idea what I'm missing?

      Comment

      Working...
      X