Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here is My Structs...
- USTRUCT(BlueprintType)
- struct FsPropertyValues : public FTableRowBase
- {
- GENERATED_USTRUCT_BODY();
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- AActor* Actor;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- UActorComponent* ActorComponent;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- UProperty* Property;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString PropertyType = "";
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- bool Value_Bool = false;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString Value_Enum = "";
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- uint8 Value_Byte = 0;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- float Value_Float = 0;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- int32 Value_Int = 0;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString Value_String = "";
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FName Value_Name = "";
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FText Value_Text;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FVector Value_Vector = FVector::FVector(0, 0, 0);
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FVector2D Value_Vector2D = FVector2D::FVector2D(0, 0);
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FRotator Value_Rotator = FRotator::FRotator(0, 0, 0);
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FTransform Value_Transform = FTransform::FTransform();
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FColor Value_Color = FColor::FColor(0, 0, 0, 0);
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FLinearColor Value_LinearColor = FLinearColor::FLinearColor(0, 0, 0, 0);
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- int32 xIndex = 0;
- };
- USTRUCT(BlueprintType)
- struct FsDataTable_Properties : public FTableRowBase
- {
- GENERATED_USTRUCT_BODY();
- public:
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString Actor;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString ActorComponent;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString Category;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString SubCategory;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString DisplayName;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- bool VisibleProperty = true;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- float UIMin = 0;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- float UIMax = 0;
- UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "CosmicIllusion")
- FString EditCondition = "";
- };
- Here My Functions to Locate Property and Set Value
- public:
- UFUNCTION(BlueprintCallable, Category = "CosmicIllusion|HUD", CustomThunk)
- static void SetHUDProperty(FsPropertyValues PropertyValue);
- DECLARE_FUNCTION(execSetHUDProperty)
- {
- PARAM_PASSED_BY_VAL(PropertyValue, UStrProperty, FsPropertyValues);
- P_FINISH;
- if (UMaterialBillboardComponent* xNullComponent = Cast<UMaterialBillboardComponent>(PropertyValue.ActorComponent)) { FindProperty(false, PropertyValue.Actor, PropertyValue); }
- else { FindProperty(true, PropertyValue.ActorComponent, PropertyValue); }
- }
- void SetPropertyInObject(bool isActorComponent, bool isActorStruct, UProperty* FindProperty, FsPropertyValues PropertyValue, void* GetValuePtr)
- {
- #if WITH_EDITOR
- if (isActorComponent) { PropertyValue.ActorComponent->PreEditChange(FindProperty); }
- else { PropertyValue.Actor->PreEditChange(FindProperty); }
- #endif
- void* ValuePtr = GetValuePtr;
- if (UStructProperty* StructProperty = Cast<UStructProperty>(PropertyValue.Property))
- {
- if (isActorStruct && isActorComponent) { ValuePtr = PropertyValue.ActorComponent; }
- else if (isActorStruct && !isActorComponent) { ValuePtr = PropertyValue.Actor; }
- if (FindProperty && PropertyValue.PropertyType == "FVector") {
- *StructProperty->ContainerPtrToValuePtr<FVector>(ValuePtr) = PropertyValue.Value_Vector;
- }
- else if (FindProperty && PropertyValue.PropertyType == "FVector2D") {
- *StructProperty->ContainerPtrToValuePtr<FVector2D>(ValuePtr) = PropertyValue.Value_Vector2D;
- }
- else if (FindProperty && PropertyValue.PropertyType == "FRotator") {
- *StructProperty->ContainerPtrToValuePtr<FRotator>(ValuePtr) = PropertyValue.Value_Rotator;
- }
- else if (FindProperty && PropertyValue.PropertyType == "FTransform") {
- *StructProperty->ContainerPtrToValuePtr<FTransform>(ValuePtr) = PropertyValue.Value_Transform;
- }
- else if (FindProperty && PropertyValue.PropertyType == "FColor") {
- *StructProperty->ContainerPtrToValuePtr<FColor>(ValuePtr) = PropertyValue.Value_Color;
- }
- else if (FindProperty && PropertyValue.PropertyType == "FLinearColor") {
- *StructProperty->ContainerPtrToValuePtr<FLinearColor>(ValuePtr) = PropertyValue.Value_LinearColor;
- }
- }
- else if (UFloatProperty* SetProperty = Cast<UFloatProperty>(FindProperty)) { SetProperty->SetFloatingPointPropertyValue(ValuePtr, PropertyValue.Value_Float); }
- else if (UByteProperty* SetProperty = Cast<UByteProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Byte); }
- else if (UInt8Property* SetProperty = Cast<UInt8Property>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UUInt32Property* SetProperty = Cast<UUInt32Property>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UUInt64Property* SetProperty = Cast<UUInt64Property>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UInt16Property* SetProperty = Cast<UInt16Property>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UInt64Property* SetProperty = Cast<UInt64Property>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UBoolProperty* SetProperty = Cast<UBoolProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Bool); }
- else if (UIntProperty* SetProperty = Cast<UIntProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Int); }
- else if (UStrProperty* SetProperty = Cast<UStrProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_String); }
- else if (UTextProperty* SetProperty = Cast<UTextProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Text); }
- else if (UNameProperty* SetProperty = Cast<UNameProperty>(FindProperty)) { SetProperty->SetPropertyValue_InContainer(ValuePtr, PropertyValue.Value_Name); }
- #if WITH_EDITOR
- if (isActorComponent) { PropertyValue.ActorComponent->PostEditChange(); }
- else { PropertyValue.Actor->PostEditChange(); }
- #endif
- }
- template <typename ObjClass> void FindProperty(bool isActorComponent, ObjClass Object, FsPropertyValues FsPropertyValue)
- {
- for (TFieldIterator<UProperty> Prop(Object->GetClass()); Prop; ++Prop)
- {
- UProperty* RootProperty = *Prop;
- if (UStructProperty* StructProperty = ExactCast<UStructProperty>(RootProperty)) {
- void* ValuePtr = StructProperty->ContainerPtrToValuePtr<void>(Object);
- IterateThroughStructProperty(isActorComponent, StructProperty, ValuePtr, FsPropertyValue);
- }
- else
- {
- void* ValuePtr = RootProperty->ContainerPtrToValuePtr<void>(Object);
- if (ParseProperty(isActorComponent, false, RootProperty, NULL, ValuePtr, FsPropertyValue, false)) { break; return; }
- }
- }
- }
- void IterateThroughStructProperty(bool isActorComponent, UStructProperty* StructProperty, void* StructPtr, FsPropertyValues PropertyValue)
- {
- UScriptStruct* Struct = StructProperty->Struct;
- for (TFieldIterator<UProperty> It(Struct); It; ++It)
- {
- if (PropertyValue.Property->GetName() == StructProperty->GetName())
- {
- UProperty* FindProperty = Cast<UProperty>(StructProperty);
- if (ParseProperty(isActorComponent, true, FindProperty, StructProperty, StructPtr, PropertyValue, true)) { break; return; }
- }
- else
- {
- UProperty* FindProperty = Struct->FindPropertyByName(PropertyValue.Property->GetFName());
- if (FindProperty)
- {
- if (ParseProperty(isActorComponent, false, FindProperty, StructProperty, StructPtr, PropertyValue, true)) { break; return; }
- }
- else
- {
- UProperty* Property = *It;
- for (int32 ArrayIndex = 0; ArrayIndex < Property->ArrayDim; ArrayIndex++)
- {
- void* ValuePtr = Property->ContainerPtrToValuePtr<void>(StructPtr, ArrayIndex);
- if (ParseProperty(isActorComponent, false, Property, StructProperty, ValuePtr, PropertyValue, false)) { break; return; }
- }
- }
- }
- }
- }
- bool ParseProperty(bool isActorComponent, bool isActorStruct, UProperty* Property, UStructProperty* StructProperty, void* ValuePtr, FsPropertyValues PropertyValue, bool isFinded)
- {
- if (isFinded || Property->GetName() == PropertyValue.Property->GetName())
- {
- SetPropertyInObject(isActorComponent, isActorStruct, Property, PropertyValue, ValuePtr);
- return true;
- }
- else if (UArrayProperty* ArrayProperty = Cast<UArrayProperty>(Property)) { FScriptArrayHelper Helper(ArrayProperty, ValuePtr); for (int32 i = 0, n = Helper.Num(); i < n; ++i) { ParseProperty(isActorComponent, isActorStruct, ArrayProperty->Inner, StructProperty, Helper.GetRawPtr(i), PropertyValue, false); } }
- else if (UStructProperty* xStructProperty = Cast<UStructProperty>(Property)) { IterateThroughStructProperty(isActorComponent, xStructProperty, ValuePtr, PropertyValue); }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement