Code:
ItemClass = ClassProperty->GetPropertyValue(ValuePtr); if(UItemBase* NewItem = NewObject<UItemBase>(this, ItemClass->GetFName())) { GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, NewItem->ItemName.ToString()); }
ItemClass = ClassProperty->GetPropertyValue(ValuePtr); if(UItemBase* NewItem = NewObject<UItemBase>(this, ItemClass->GetFName())) { GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, NewItem->ItemName.ToString()); }
void UItemMaster::HandleStruct(FProperty* Property, void* StructPtr) { int64 ItemHash = 0; TSubclassOf<UItemBase> ItemClass; FStructProperty* StructProperty = CastField<FStructProperty>(Property); if (StructProperty) { TFieldIterator<FProperty> PropertyIterator(StructProperty->Struct); for (PropertyIterator; PropertyIterator; ++PropertyIterator) { for (int32 ArrayIndex = 0; ArrayIndex < PropertyIterator->ArrayDim; ArrayIndex++) { void* ValuePtr = PropertyIterator->ContainerPtrToValuePtr<void>(StructPtr, ArrayIndex); if (PropertyIterator->GetAuthoredName() == TEXT("ItemClass")) { if (FClassProperty* ClassProperty = CastField<FClassProperty>(*PropertyIterator)) { GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, *ClassProperty->GetName()); // here i need to convert ClassProperty to TSubclassOf<> } } } } } }
Leave a comment: