static void CreateVariables(UUserDefinedStruct* Struct, const class UEdGraphSchema_K2* Schema, FCompilerResultsLog& MessageLog) { check(Struct && Schema); //FKismetCompilerUtilities::LinkAddedProperty push property to begin, so we revert the order for (int32 VarDescIdx = FStructureEditorUtils::GetVarDesc(Struct).Num() - 1; VarDescIdx >= 0; --VarDescIdx) { FStructVariableDescription& VarDesc = FStructureEditorUtils::GetVarDesc(Struct)[VarDescIdx]; VarDesc.bInvalidMember = true; FEdGraphPinType VarType = VarDesc.ToPinType(); FString ErrorMsg; if(!FStructureEditorUtils::CanHaveAMemberVariableOfType(Struct, VarType, &ErrorMsg)) { LogError(Struct, MessageLog, FString::Printf(*LOCTEXT("StructureGeneric_Error", "Structure: %s Error: %s").ToString(), *Struct->GetFullName(), *ErrorMsg)); continue; } UProperty* NewProperty = FKismetCompilerUtilities::CreatePropertyOnScope(Struct, VarDesc.VarName, VarType, NULL, 0, Schema, MessageLog); if (NewProperty != NULL) { NewProperty->SetFlags(RF_LoadCompleted); FKismetCompilerUtilities::LinkAddedProperty(Struct, NewProperty); } else { LogError(Struct, MessageLog, FString::Printf(*LOCTEXT("VariableInvalidType_Error", "The variable %s declared in %s has an invalid type %s").ToString(), *VarDesc.VarName.ToString(), *Struct->GetName(), *UEdGraphSchema_K2::TypeToText(VarType).ToString())); continue; } NewProperty->SetPropertyFlags(CPF_Edit | CPF_BlueprintVisible); if (VarDesc.bDontEditoOnInstance) { NewProperty->SetPropertyFlags(CPF_DisableEditOnInstance); } if (VarDesc.bEnable3dWidget) { NewProperty->SetMetaData(FEdMode::MD_MakeEditWidget, TEXT("true")); } NewProperty->SetMetaData(TEXT("DisplayName"), *VarDesc.FriendlyName); NewProperty->SetMetaData(FBlueprintMetadata::MD_Tooltip, *VarDesc.ToolTip); NewProperty->RepNotifyFunc = NAME_None; if (!VarDesc.DefaultValue.IsEmpty()) { NewProperty->SetMetaData(TEXT("MakeStructureDefaultValue"), *VarDesc.DefaultValue); } VarDesc.CurrentDefaultValue = VarDesc.DefaultValue; VarDesc.bInvalidMember = false; } }