// Copyright Epic Games, Inc. All Rights Reserved. #include "DataInterfaceGraph_EdGraphSchema.h" #include "Editor.h" void UDataInterfaceGraph_EdGraphSchema::TrySetDefaultValue(UEdGraphPin& InPin, const FString& InNewDefaultValue, bool bMarkAsModified) const { #if WITH_EDITOR if (GEditor) { GEditor->CancelTransaction(0); } #endif FString UseDefaultValue; TObjectPtr UseDefaultObject = nullptr; FText UseDefaultText; GetDefault()->GetPinDefaultValuesFromString(InPin.PinType, InPin.GetOwningNodeUnchecked(), InNewDefaultValue, UseDefaultValue, UseDefaultObject, UseDefaultText, /*bPreserveTextIdentity*/false); // Check the default value and make it an error if it's bogus if (GetDefault()->DefaultValueSimpleValidation(InPin.PinType, InPin.PinName, UseDefaultValue, UseDefaultObject, UseDefaultText)) { InPin.DefaultObject = UseDefaultObject; InPin.DefaultValue = UseDefaultValue; InPin.DefaultTextValue = UseDefaultText; UEdGraphNode* Node = InPin.GetOwningNode(); Node->PinDefaultValueChanged(&InPin); // If the default value is manually set then treat it as if the value was reset to default and remove the orphaned InPin if (InPin.bOrphanedPin && InPin.DoesDefaultValueMatchAutogenerated()) { Node->PinConnectionListChanged(&InPin); } if (bMarkAsModified) { Node->MarkPackageDirty(); } } }