|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "UnrealEd.h" |
| 4 | +#include "PyFactory.generated.h" |
| 5 | + |
| 6 | +UCLASS() |
| 7 | +class UPyFactory : public UFactory |
| 8 | +{ |
| 9 | + GENERATED_BODY() |
| 10 | + |
| 11 | +public: |
| 12 | + |
| 13 | + virtual UObject* FactoryCreateFile(UClass * Class, UObject *InParent, FName InName, EObjectFlags Flags, const FString& Filename, const TCHAR* Parms, FFeedbackContext *Warn, bool& bOutOperationCanceled) override { |
| 14 | + return PyFactoryCreateFile(Class, InParent, InName.ToString(), Filename); |
| 15 | + } |
| 16 | + |
| 17 | + virtual UObject* FactoryCreateNew(UClass * Class, UObject *InParent, FName InName, EObjectFlags Flags, UObject *Context, FFeedbackContext *Warn) override { |
| 18 | + return PyFactoryCreateNew(Class, InParent, InName.ToString()); |
| 19 | + } |
| 20 | + |
| 21 | + virtual UClass* ResolveSupportedClass() override { |
| 22 | + if (SupportedClass) |
| 23 | + return SupportedClass; |
| 24 | + return PyResolveSupportedClass(); |
| 25 | + } |
| 26 | + |
| 27 | + virtual FText GetDisplayName() const override { |
| 28 | + if (!PyDisplayName.IsEmpty()) { |
| 29 | + return FText::FromString(PyDisplayName); |
| 30 | + } |
| 31 | + return FText::FromString(GetClass()->GetName().Replace(UTF8_TO_TCHAR("Factory"), UTF8_TO_TCHAR(""))); |
| 32 | + } |
| 33 | + |
| 34 | + virtual FText GetToolTip() const override { |
| 35 | + if (!PyToolTip.IsEmpty()) { |
| 36 | + return FText::FromString(PyToolTip); |
| 37 | + } |
| 38 | + return GetDisplayName(); |
| 39 | + } |
| 40 | + |
| 41 | + UFUNCTION(BlueprintImplementableEvent) |
| 42 | + UObject* PyFactoryCreateFile(class UClass * Class, UObject *InParent, const FString & InName, const FString & Filename); |
| 43 | + |
| 44 | + UFUNCTION(BlueprintImplementableEvent) |
| 45 | + UObject* PyFactoryCreateNew(class UClass * Class, UObject *InParent, const FString & InName); |
| 46 | + |
| 47 | + UFUNCTION(BlueprintImplementableEvent) |
| 48 | + UClass* PyResolveSupportedClass(); |
| 49 | + |
| 50 | + UPROPERTY(BlueprintReadWrite, Category = "PyFactory") |
| 51 | + FString PyDisplayName; |
| 52 | + |
| 53 | + UPROPERTY(BlueprintReadWrite, Category = "PyFactory") |
| 54 | + FString PyToolTip; |
| 55 | + |
| 56 | +}; |
| 57 | + |
| 58 | + |
0 commit comments