More work on property
This commit is contained in:
46
Plugins/UEWingman/Source/UEWingman/Handlers/Details_Set.h
Normal file
46
Plugins/UEWingman/Source/UEWingman/Handlers/Details_Set.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "WingServer.h"
|
||||
#include "WingHandler.h"
|
||||
#include "WingFetcher.h"
|
||||
#include "WingPropHandle.h"
|
||||
#include "WingUtils.h"
|
||||
#include "Details_Set.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class UWing_Details_Set : public UWingHandler
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(meta=(Description="Target object"))
|
||||
FString Object;
|
||||
|
||||
UPROPERTY(meta=(Description="Property name"))
|
||||
FString Property;
|
||||
|
||||
UPROPERTY(meta=(Description="New value in Unreal text format"))
|
||||
FString Value;
|
||||
|
||||
virtual void Register() override
|
||||
{
|
||||
UWingServer::AddHandler(this,
|
||||
TEXT("Set a single editable property. Value uses Unreal text format."));
|
||||
}
|
||||
|
||||
virtual void Handle() override
|
||||
{
|
||||
WingFetcher F;
|
||||
UObject* Obj = F.Walk(Object).Cast<UObject>();
|
||||
if (!Obj) return;
|
||||
|
||||
WingPropHandle Props;
|
||||
WingPropHandle::Handles Handles = Props.GetDetails(Obj, true);
|
||||
TSharedPtr<IPropertyHandle>* P = WingUtils::FindOneWithExternalID(Property, Handles, TEXT("Property"));
|
||||
if (!P) return;
|
||||
|
||||
if (WingPropHandle::SetText(**P, Value))
|
||||
UWingServer::Print(TEXT("OK\n"));
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user