本文整理汇总了C++中UProperty::GetOuter方法的典型用法代码示例。如果您正苦于以下问题:C++ UProperty::GetOuter方法的具体用法?C++ UProperty::GetOuter怎么用?C++ UProperty::GetOuter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UProperty
的用法示例。
在下文中一共展示了UProperty::GetOuter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CollectPropertyDescription
FString CollectPropertyDescription(const UObject* Ob, const UClass* StopAtClass, const TArray<UProperty*>& PropertyData)
{
FString RetString;
for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext)
{
// stop when reaching base class
if (TestProperty->GetOuter() == StopAtClass)
{
break;
}
// skip properties without any setup data
if (TestProperty->HasAnyPropertyFlags(CPF_Transient) ||
TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance) ||
PropertyData.Contains(TestProperty))
{
continue;
}
if (TestProperty->IsA(UClassProperty::StaticClass()) ||
TestProperty->IsA(UStructProperty::StaticClass()) ||
CanUsePropertyType(TestProperty))
{
if (RetString.Len())
{
RetString.AppendChar(TEXT('\n'));
}
const uint8* PropData = TestProperty->ContainerPtrToValuePtr<uint8>(Ob);
RetString += DescribeProperty(TestProperty, PropData);
}
}
return RetString;
}
示例2: CollectPropertyData
void CollectPropertyData(const UObject* Ob, const UClass* StopAtClass, TArray<UProperty*>& PropertyData)
{
UE_LOG(LogBehaviorTree, Verbose, TEXT("Looking for runtime properties of class: %s"), *GetNameSafe(Ob->GetClass()));
PropertyData.Reset();
for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext)
{
// stop when reaching base class
if (TestProperty->GetOuter() == StopAtClass)
{
break;
}
// skip properties without any setup data
if (TestProperty->HasAnyPropertyFlags(CPF_Transient) ||
TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance) == false)
{
continue;
}
// serialize only simple types
if (CanUsePropertyType(TestProperty))
{
UE_LOG(LogBehaviorTree, Verbose, TEXT("> name: '%s'"), *GetNameSafe(TestProperty));
PropertyData.Add(TestProperty);
}
}
}
示例3: IsPropertyExtendable
bool FDetailWidgetExtensionHandler::IsPropertyExtendable(const UClass* InObjectClass, const IPropertyHandle& InPropertyHandle) const
{
// TODO UMG make this work for multiple widgets.
if ( InPropertyHandle.GetNumOuterObjects() == 1 )
{
TArray<UObject*> Objects;
InPropertyHandle.GetOuterObjects(Objects);
// We don't allow bindings on the CDO.
if ( Objects[0]->HasAnyFlags(RF_ClassDefaultObject) )
{
return false;
}
UProperty* Property = InPropertyHandle.GetProperty();
FString DelegateName = Property->GetName() + "Delegate";
if ( UClass* ContainerClass = Cast<UClass>(Property->GetOuter()) )
{
UDelegateProperty* DelegateProperty = FindField<UDelegateProperty>(ContainerClass, FName(*DelegateName));
if ( DelegateProperty )
{
return true;
}
}
}
return false;
}
示例4: CollectBlackboardSelectors
void CollectBlackboardSelectors(const UObject* Ob, const UClass* StopAtClass, TArray<FName>& KeyNames)
{
for (UProperty* TestProperty = Ob->GetClass()->PropertyLink; TestProperty; TestProperty = TestProperty->PropertyLinkNext)
{
// stop when reaching base class
if (TestProperty->GetOuter() == StopAtClass)
{
break;
}
// skip properties without any setup data
if (TestProperty->HasAnyPropertyFlags(CPF_Transient) ||
TestProperty->HasAnyPropertyFlags(CPF_DisableEditOnInstance))
{
continue;
}
const UStructProperty* StructProp = Cast<const UStructProperty>(TestProperty);
if (StructProp && StructProp->GetCPPType(NULL, CPPF_None).Contains(GET_STRUCT_NAME_CHECKED(FBlackboardKeySelector)))
{
const FBlackboardKeySelector* PropData = TestProperty->ContainerPtrToValuePtr<FBlackboardKeySelector>(Ob);
KeyNames.AddUnique(PropData->SelectedKeyName);
}
}
}
示例5: CreatePin
void UK2Node_SpawnActor::CreatePinsForClass(UClass* InClass)
{
check(InClass != NULL);
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Property = *PropertyIt;
UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter());
const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass());
const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property);
const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance);
if( bIsExposedToSpawn &&
!Property->HasAnyPropertyFlags(CPF_Parm) &&
bIsSettableExternally &&
Property->HasAllPropertyFlags(CPF_BlueprintVisible) &&
!bIsDelegate )
{
UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName());
const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType);
}
}
// Change class of output pin
UEdGraphPin* ResultPin = GetResultPin();
ResultPin->PinType.PinSubCategoryObject = InClass;
}
示例6: ResetPropertiesForConstruction
void AActor::ResetPropertiesForConstruction()
{
// Get class CDO
AActor* Default = GetClass()->GetDefaultObject<AActor>();
// RandomStream struct name to compare against
const FName RandomStreamName(TEXT("RandomStream"));
// We don't want to reset references to world object
const bool bIsLevelScriptActor = IsA(ALevelScriptActor::StaticClass());
// Iterate over properties
for( TFieldIterator<UProperty> It(GetClass()) ; It ; ++It )
{
UProperty* Prop = *It;
UStructProperty* StructProp = Cast<UStructProperty>(Prop);
UClass* PropClass = CastChecked<UClass>(Prop->GetOuter()); // get the class that added this property
// First see if it is a random stream, if so reset before running construction script
if( (StructProp != NULL) && (StructProp->Struct != NULL) && (StructProp->Struct->GetFName() == RandomStreamName) )
{
FRandomStream* StreamPtr = StructProp->ContainerPtrToValuePtr<FRandomStream>(this);
StreamPtr->Reset();
}
// If it is a blueprint added variable that is not editable per-instance, reset to default before running construction script
else if( !bIsLevelScriptActor
&& Prop->HasAnyPropertyFlags(CPF_DisableEditOnInstance)
&& PropClass->HasAnyClassFlags(CLASS_CompiledFromBlueprint)
&& !Prop->IsA(UDelegateProperty::StaticClass())
&& !Prop->IsA(UMulticastDelegateProperty::StaticClass()) )
{
Prop->CopyCompleteValue_InContainer(this, Default);
}
}
}
示例7: ScanForChanges
/**
* Scans for changes to the value
*
* @param bRecacheNewValues If true, recaches new values found
* @return true if any changes were found
*/
bool ScanForChanges( bool bRecacheNewValues )
{
FPropertyNode& PropertyNodeRef = *PropertyNode.Pin();
UProperty* Property = PropertyNodeRef.GetProperty();
bool bPropertyValid = true;
bool bChanged = false;
UArrayProperty* OuterArrayProperty = Cast<UArrayProperty>( Property->GetOuter() );
if ( OuterArrayProperty != NULL )
{
// make sure we're not trying to compare against an element that doesn't exist
if ( PropertyNodeRef.GetArrayIndex() >= FScriptArrayHelper::Num( PropertyValueBaseAddress ) )
{
bPropertyValid = false;
}
}
if( bPropertyValid )
{
bChanged = !Property->Identical( PropertyValueAddress, Data.GetData() );
if( bRecacheNewValues )
{
CacheValue();
}
}
return bChanged;
}
示例8: SaveClassFieldMapping
void FBlueprintCompileReinstancer::SaveClassFieldMapping(UClass* InClassToReinstance)
{
check(InClassToReinstance);
for (UProperty* Prop = InClassToReinstance->PropertyLink; Prop && (Prop->GetOuter() == InClassToReinstance); Prop = Prop->PropertyLinkNext)
{
PropertyMap.Add(Prop->GetFName(), Prop);
}
for (auto Function : TFieldRange<UFunction>(InClassToReinstance, EFieldIteratorFlags::ExcludeSuper))
{
FunctionMap.Add(Function->GetFName(),Function);
}
}
示例9: FindPin
void UK2Node_SpawnActorFromClass::CreatePinsForClass(UClass* InClass, TArray<UEdGraphPin*>& OutClassPins)
{
check(InClass != NULL);
const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>();
const UObject* const ClassDefaultObject = InClass->GetDefaultObject(false);
for (TFieldIterator<UProperty> PropertyIt(InClass, EFieldIteratorFlags::IncludeSuper); PropertyIt; ++PropertyIt)
{
UProperty* Property = *PropertyIt;
UClass* PropertyClass = CastChecked<UClass>(Property->GetOuter());
const bool bIsDelegate = Property->IsA(UMulticastDelegateProperty::StaticClass());
const bool bIsExposedToSpawn = UEdGraphSchema_K2::IsPropertyExposedOnSpawn(Property);
const bool bIsSettableExternally = !Property->HasAnyPropertyFlags(CPF_DisableEditOnInstance);
if( bIsExposedToSpawn &&
!Property->HasAnyPropertyFlags(CPF_Parm) &&
bIsSettableExternally &&
Property->HasAllPropertyFlags(CPF_BlueprintVisible) &&
!bIsDelegate &&
(NULL == FindPin(Property->GetName()) ) )
{
UEdGraphPin* Pin = CreatePin(EGPD_Input, TEXT(""), TEXT(""), NULL, false, false, Property->GetName());
const bool bPinGood = (Pin != NULL) && K2Schema->ConvertPropertyToPinType(Property, /*out*/ Pin->PinType);
OutClassPins.Add(Pin);
if (ClassDefaultObject && Pin != NULL && K2Schema->PinDefaultValueIsEditable(*Pin))
{
FString DefaultValueAsString;
const bool bDefaultValueSet = FBlueprintEditorUtils::PropertyValueToString(Property, reinterpret_cast<const uint8*>(ClassDefaultObject), DefaultValueAsString);
check( bDefaultValueSet );
K2Schema->TrySetDefaultValue(*Pin, DefaultValueAsString);
}
// Copy tooltip from the property.
if (Pin != nullptr)
{
K2Schema->ConstructBasicPinTooltip(*Pin, Property->GetToolTipText(), Pin->PinToolTip);
}
}
}
// Change class of output pin
UEdGraphPin* ResultPin = GetResultPin();
ResultPin->PinType.PinSubCategoryObject = InClass;
}
示例10: InitFromMetaDataTable
void UAttributeSet::InitFromMetaDataTable(const UDataTable* DataTable)
{
static const FString Context = FString(TEXT("UAttribute::BindToMetaDataTable"));
for( TFieldIterator<UProperty> It(GetClass(), EFieldIteratorFlags::IncludeSuper) ; It ; ++It )
{
UProperty* Property = *It;
UNumericProperty *NumericProperty = Cast<UNumericProperty>(Property);
if (NumericProperty)
{
FString RowNameStr = FString::Printf(TEXT("%s.%s"), *Property->GetOuter()->GetName(), *Property->GetName());
FAttributeMetaData * MetaData = DataTable->FindRow<FAttributeMetaData>(FName(*RowNameStr), Context, false);
if (MetaData)
{
void *Data = NumericProperty->ContainerPtrToValuePtr<void>(this);
NumericProperty->SetFloatingPointPropertyValue(Data, MetaData->BaseValue);
}
}
}
PrintDebug();
}
示例11: PropertyNode
FValueCache( TSharedRef<FPropertyNode> InPropertyNode, UObject* InOwnerObject )
: PropertyNode( InPropertyNode )
{
PropertyValueRoot.OwnerObject = InOwnerObject;
UProperty* Property = InPropertyNode->GetProperty();
check(Property);
check(PropertyValueRoot.OwnerObject);
FPropertyNode* ParentNode = InPropertyNode->GetParentNode();
//UArrayProperty* ArrayProp = Cast<UArrayProperty>(Property);
UArrayProperty* OuterArrayProp = Cast<UArrayProperty>(Property->GetOuter());
// calculate the values for the current object
PropertyValueBaseAddress = OuterArrayProp == NULL
? InPropertyNode->GetValueBaseAddress(PropertyValueRoot.ValueAddress)
: ParentNode->GetValueBaseAddress(PropertyValueRoot.ValueAddress);
PropertyValueAddress = InPropertyNode->GetValueAddress(PropertyValueRoot.ValueAddress);
}
示例12: Construct
void SPropertyEditorAsset::Construct( const FArguments& InArgs, const TSharedPtr<FPropertyEditor>& InPropertyEditor )
{
PropertyEditor = InPropertyEditor;
PropertyHandle = InArgs._PropertyHandle;
OnSetObject = InArgs._OnSetObject;
OnShouldFilterAsset = InArgs._OnShouldFilterAsset;
UProperty* Property = nullptr;
if(PropertyEditor.IsValid())
{
Property = PropertyEditor->GetPropertyNode()->GetProperty();
UObjectPropertyBase* ObjectProperty = Cast<UObjectPropertyBase>(Property);
check(ObjectProperty);
bAllowClear = !(Property->PropertyFlags & CPF_NoClear);
ObjectClass = ObjectProperty->PropertyClass;
bIsActor = ObjectProperty->PropertyClass->IsChildOf( AActor::StaticClass() );
}
else
{
bAllowClear = InArgs._AllowClear;
ObjectPath = InArgs._ObjectPath;
ObjectClass = InArgs._Class;
bIsActor = ObjectClass->IsChildOf( AActor::StaticClass() );
if (PropertyHandle.IsValid() && PropertyHandle->IsValidHandle())
{
Property = PropertyHandle->GetProperty();
}
else
{
CustomClassFilters.Add(ObjectClass);
}
}
// Account for the allowed classes specified in the property metadata
if (Property)
{
FString ClassFilterString;
if (UArrayProperty* ArrayParent = Cast<UArrayProperty>(Property->GetOuter()))
{
ClassFilterString = ArrayParent->GetMetaData("AllowedClasses");
}
else
{
ClassFilterString = Property->GetMetaData("AllowedClasses");
}
if (ClassFilterString.IsEmpty())
{
CustomClassFilters.Add(ObjectClass);
}
else
{
TArray<FString> CustomClassFilterNames;
ClassFilterString.ParseIntoArray(CustomClassFilterNames, TEXT(","), true);
for (auto It = CustomClassFilterNames.CreateConstIterator(); It; ++It)
{
const FString& ClassName = *It;
UClass* Class = FindObject<UClass>(ANY_PACKAGE, *ClassName);
if (!Class)
{
Class = LoadObject<UClass>(nullptr, *ClassName);
}
if (Class)
{
// If the class is an interface, expand it to be all classes in memory that implement the class.
if (Class->HasAnyClassFlags(CLASS_Interface))
{
for (TObjectIterator<UClass> ClassIt; ClassIt; ++ClassIt)
{
UClass* const ClassWithInterface = (*ClassIt);
if (ClassWithInterface->ImplementsInterface(Class))
{
CustomClassFilters.Add(ClassWithInterface);
}
}
}
else
{
CustomClassFilters.Add(Class);
}
}
}
}
}
if (InArgs._NewAssetFactories.IsSet())
{
NewAssetFactories = InArgs._NewAssetFactories.GetValue();
}
else if (CustomClassFilters.Num() > 1 || !CustomClassFilters.Contains(UObject::StaticClass()))
{
NewAssetFactories = PropertyCustomizationHelpers::GetNewAssetFactoriesForClasses(CustomClassFilters);
}
//.........这里部分代码省略.........
示例13: GetReadAddressUncached
bool FObjectPropertyNode::GetReadAddressUncached(FPropertyNode& InNode,
bool InRequiresSingleSelection,
FReadAddressListData& OutAddresses,
bool bComparePropertyContents,
bool bObjectForceCompare,
bool bArrayPropertiesCanDifferInSize) const
{
// Are any objects selected for property editing?
if( !GetNumObjects())
{
return false;
}
UProperty* InItemProperty = InNode.GetProperty();
// Is there a InItemProperty bound to the InItemProperty window?
if( !InItemProperty )
{
return false;
}
// Requesting a single selection?
if( InRequiresSingleSelection && GetNumObjects() > 1)
{
// Fail: we're editing properties for multiple objects.
return false;
}
//assume all properties are the same unless proven otherwise
bool bAllTheSame = true;
//////////////////////////////////////////
// If this item is the child of an array, return NULL if there is a different number
// of items in the array in different objects, when multi-selecting.
if( Cast<UArrayProperty>(InItemProperty->GetOuter()) )
{
FPropertyNode* ParentNode = InNode.GetParentNode();
check(ParentNode);
const UObject* TempObject = GetUObject(0);
if( TempObject )
{
uint8* BaseAddr = ParentNode->GetValueBaseAddress( (uint8*)TempObject );
if( BaseAddr )
{
const int32 Num = FScriptArrayHelper::Num(BaseAddr);
for( int32 ObjIndex = 1 ; ObjIndex < GetNumObjects(); ObjIndex++ )
{
TempObject = GetUObject(ObjIndex);
BaseAddr = ParentNode->GetValueBaseAddress( (uint8*)TempObject );
if( BaseAddr && Num != FScriptArrayHelper::Num( BaseAddr ) )
{
bAllTheSame = false;
}
}
}
}
}
uint8* Base = GetUObject(0) ? InNode.GetValueBaseAddress( (uint8*)(GetUObject(0)) ) : NULL;
if (Base)
{
// If the item is an array itself, return NULL if there are a different number of
// items in the array in different objects, when multi-selecting.
if( Cast<UArrayProperty>(InItemProperty) )
{
// This flag is an override for array properties which want to display e.g. the "Clear" and "Empty"
// buttons, even though the array properties may differ in the number of elements.
if ( !bArrayPropertiesCanDifferInSize )
{
const UObject* TempObject = GetUObject(0);
int32 const Num = FScriptArrayHelper::Num(InNode.GetValueBaseAddress( (uint8*)TempObject));
for( int32 ObjIndex = 1 ; ObjIndex < GetNumObjects() ; ObjIndex++ )
{
TempObject = GetUObject(ObjIndex);
if( TempObject && Num != FScriptArrayHelper::Num(InNode.GetValueBaseAddress((uint8*)TempObject)) )
{
bAllTheSame = false;
}
}
}
}
else
{
if ( bComparePropertyContents || !Cast<UObjectPropertyBase>(InItemProperty) || bObjectForceCompare )
{
// Make sure the value of this InItemProperty is the same in all selected objects.
for( int32 ObjIndex = 1 ; ObjIndex < GetNumObjects() ; ObjIndex++ )
{
const UObject* TempObject = GetUObject(ObjIndex);
if( !InItemProperty->Identical( Base, InNode.GetValueBaseAddress( (uint8*)TempObject ) ) )
{
bAllTheSame = false;
}
}
}
else
{
//.........这里部分代码省略.........
示例14: DroppedOnPanel
FReply FKismetVariableDragDropAction::DroppedOnPanel( const TSharedRef< SWidget >& Panel, FVector2D ScreenPosition, FVector2D GraphPosition, UEdGraph& Graph)
{
if (Cast<const UEdGraphSchema_K2>(Graph.GetSchema()) != NULL)
{
UProperty* VariableProperty = GetVariableProperty();
if (VariableProperty != nullptr && CanVariableBeDropped(VariableProperty, Graph))
{
UStruct* Outer = CastChecked<UStruct>(VariableProperty->GetOuter());
FNodeConstructionParams NewNodeParams;
NewNodeParams.VariableName = VariableName;
NewNodeParams.Graph = &Graph;
NewNodeParams.GraphPosition = GraphPosition;
NewNodeParams.VariableSource= Outer;
// call analytics
AnalyticCallback.ExecuteIfBound();
// Take into account current state of modifier keys in case the user changed his mind
auto ModifierKeys = FSlateApplication::Get().GetModifierKeys();
const bool bModifiedKeysActive = ModifierKeys.IsControlDown() || ModifierKeys.IsAltDown();
const bool bAutoCreateGetter = bModifiedKeysActive ? ModifierKeys.IsControlDown() : bControlDrag;
const bool bAutoCreateSetter = bModifiedKeysActive ? ModifierKeys.IsAltDown() : bAltDrag;
// Handle Getter/Setters
if (bAutoCreateGetter || bAutoCreateSetter)
{
if (bAutoCreateGetter || !CanExecuteMakeSetter(NewNodeParams, VariableProperty))
{
MakeGetter(NewNodeParams);
NewNodeParams.GraphPosition.Y += 50.f;
}
if (bAutoCreateSetter && CanExecuteMakeSetter( NewNodeParams, VariableProperty))
{
MakeSetter(NewNodeParams);
}
}
// Show selection menu
else
{
FMenuBuilder MenuBuilder(true, NULL);
const FText VariableNameText = FText::FromName( VariableName );
MenuBuilder.BeginSection("BPVariableDroppedOn", VariableNameText );
MenuBuilder.AddMenuEntry(
LOCTEXT("CreateGetVariable", "Get"),
FText::Format( LOCTEXT("CreateVariableGetterToolTip", "Create Getter for variable '{0}'\n(Ctrl-drag to automatically create a getter)"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetVariableDragDropAction::MakeGetter, NewNodeParams), FCanExecuteAction())
);
MenuBuilder.AddMenuEntry(
LOCTEXT("CreateSetVariable", "Set"),
FText::Format( LOCTEXT("CreateVariableSetterToolTip", "Create Setter for variable '{0}'\n(Alt-drag to automatically create a setter)"), VariableNameText ),
FSlateIcon(),
FUIAction(
FExecuteAction::CreateStatic(&FKismetVariableDragDropAction::MakeSetter, NewNodeParams),
FCanExecuteAction::CreateStatic(&FKismetVariableDragDropAction::CanExecuteMakeSetter, NewNodeParams, VariableProperty ))
);
TSharedRef< SWidget > PanelWidget = Panel;
// Show dialog to choose getter vs setter
FSlateApplication::Get().PushMenu(
PanelWidget,
FWidgetPath(),
MenuBuilder.MakeWidget(),
ScreenPosition,
FPopupTransitionEffect( FPopupTransitionEffect::ContextMenu)
);
MenuBuilder.EndSection();
}
}
}
return FReply::Handled();
}
示例15: HoverTargetChanged
void FKismetVariableDragDropAction::HoverTargetChanged()
{
UProperty* VariableProperty = GetVariableProperty();
if (VariableProperty == nullptr)
{
return;
}
FString VariableString = VariableName.ToString();
// Icon/text to draw on tooltip
FSlateColor IconColor = FLinearColor::White;
const FSlateBrush* StatusSymbol = FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
FText Message = LOCTEXT("InvalidDropTarget", "Invalid drop target!");
UEdGraphPin* PinUnderCursor = GetHoveredPin();
bool bCanMakeSetter = true;
bool bBadSchema = false;
bool bBadGraph = false;
UEdGraph* HoveredGraph = GetHoveredGraph();
if (HoveredGraph)
{
if (Cast<const UEdGraphSchema_K2>(HoveredGraph->GetSchema()) == NULL)
{
bBadSchema = true;
}
else if(!CanVariableBeDropped(VariableProperty, *HoveredGraph))
{
bBadGraph = true;
}
UStruct* Outer = CastChecked<UStruct>(VariableProperty->GetOuter());
FNodeConstructionParams NewNodeParams;
NewNodeParams.VariableName = VariableName;
const UBlueprint* DropOnBlueprint = FBlueprintEditorUtils::FindBlueprintForGraph(HoveredGraph);
NewNodeParams.Graph = HoveredGraph;
NewNodeParams.VariableSource = Outer;
bCanMakeSetter = CanExecuteMakeSetter(NewNodeParams, VariableProperty);
}
UEdGraphNode* VarNodeUnderCursor = Cast<UK2Node_Variable>(GetHoveredNode());
if (bBadSchema)
{
StatusSymbol = FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
Message = LOCTEXT("CannotCreateInThisSchema", "Cannot access variables in this type of graph");
}
else if(bBadGraph)
{
FFormatNamedArguments Args;
Args.Add(TEXT("VariableName"), FText::FromString(VariableString));
Args.Add(TEXT("Scope"), FText::FromString(HoveredGraph->GetName()));
StatusSymbol = FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.Error"));
if(IsFromBlueprint(FBlueprintEditorUtils::FindBlueprintForGraph(HoveredGraph)) && VariableProperty->GetOuter()->IsA(UFunction::StaticClass()))
{
Message = FText::Format( LOCTEXT("IncorrectGraphForLocalVariable_Error", "Cannot place local variable '{VariableName}' in external scope '{Scope}'"), Args);
}
else
{
Message = FText::Format( LOCTEXT("IncorrectGraphForVariable_Error", "Cannot place variable '{VariableName}' in external scope '{Scope}'"), Args);
}
}
else if (PinUnderCursor != NULL)
{
FFormatNamedArguments Args;
Args.Add(TEXT("PinUnderCursor"), FText::FromString(PinUnderCursor->PinName));
Args.Add(TEXT("VariableName"), FText::FromString(VariableString));
if(CanVariableBeDropped(VariableProperty, *PinUnderCursor->GetOwningNode()->GetGraph()))
{
const UEdGraphSchema_K2* Schema = CastChecked<const UEdGraphSchema_K2>(PinUnderCursor->GetSchema());
const bool bIsRead = PinUnderCursor->Direction == EGPD_Input;
const UBlueprint* Blueprint = FBlueprintEditorUtils::FindBlueprintForNode(PinUnderCursor->GetOwningNode());
const bool bReadOnlyProperty = FBlueprintEditorUtils::IsPropertyReadOnlyInCurrentBlueprint(Blueprint, VariableProperty);
const bool bCanWriteIfNeeded = bIsRead || !bReadOnlyProperty;
FEdGraphPinType VariablePinType;
Schema->ConvertPropertyToPinType(VariableProperty, VariablePinType);
const bool bTypeMatch = Schema->ArePinTypesCompatible(VariablePinType, PinUnderCursor->PinType);
Args.Add(TEXT("PinUnderCursor"), FText::FromString(PinUnderCursor->PinName));
if (bTypeMatch && bCanWriteIfNeeded)
{
StatusSymbol = FEditorStyle::GetBrush(TEXT("Graph.ConnectorFeedback.OK"));
if (bIsRead)
{
Message = FText::Format(LOCTEXT("MakeThisEqualThat_PinEqualVariableName", "Make {PinUnderCursor} = {VariableName}"), Args);
}
else
{
Message = FText::Format(LOCTEXT("MakeThisEqualThat_VariableNameEqualPin", "Make {VariableName} = {PinUnderCursor}"), Args);
}
//.........这里部分代码省略.........