void AActor::PreEditUndo() { // Check if this Actor needs to be re-instanced UClass* OldClass = GetClass(); UClass* NewClass = OldClass->GetAuthoritativeClass(); if (NewClass != OldClass) { // Empty the OwnedComponents array, it's filled with invalid information OwnedComponents.Empty(); } // Since child actor components will rebuild themselves get rid of the Actor before we make changes TInlineComponentArray<UChildActorComponent*> ChildActorComponents; GetComponents(ChildActorComponents); for (UChildActorComponent* ChildActorComponent : ChildActorComponents) { if (ChildActorComponent->IsCreatedByConstructionScript()) { ChildActorComponent->DestroyChildActor(); } } // let navigation system know to not care about this actor anymore UNavigationSystem::ClearNavOctreeAll(this); Super::PreEditUndo(); }
void UK2Node_Variable::AutowireNewNode(UEdGraphPin* FromPin) { const UEdGraphSchema_K2* K2Schema = CastChecked<UEdGraphSchema_K2>(GetSchema()); // Do some auto-connection if (FromPin != NULL) { bool bConnected = false; if(FromPin->Direction == EGPD_Output) { // If the source pin has a valid PinSubCategoryObject, we might be doing BP Comms, so check if it is a class if(FromPin->PinType.PinSubCategoryObject.IsValid() && FromPin->PinType.PinSubCategoryObject->IsA(UClass::StaticClass())) { UProperty* VariableProperty = VariableReference.ResolveMember<UProperty>(GetBlueprintClassFromNode()); if(VariableProperty) { UClass* PropertyOwner = VariableProperty->GetOwnerClass(); if (PropertyOwner != nullptr) { PropertyOwner = PropertyOwner->GetAuthoritativeClass(); } // BP Comms is highly likely at this point, if the source pin's type is a child of the variable's owner class, let's conform the "Target" pin if(FromPin->PinType.PinSubCategoryObject == PropertyOwner || dynamic_cast<UClass*>(FromPin->PinType.PinSubCategoryObject.Get())->IsChildOf(PropertyOwner)) { UEdGraphPin* TargetPin = FindPin(K2Schema->PN_Self); if (TargetPin) { TargetPin->PinType.PinSubCategoryObject = PropertyOwner; if(K2Schema->TryCreateConnection(FromPin, TargetPin)) { bConnected = true; // Setup the VariableReference correctly since it may no longer be a self member VariableReference.SetFromField<UProperty>(GetPropertyForVariable(), false); TargetPin->bHidden = false; FromPin->GetOwningNode()->NodeConnectionListChanged(); this->NodeConnectionListChanged(); } } } } } } if(!bConnected) { Super::AutowireNewNode(FromPin); } } }
// @todo: move this to FKismetEditorUtilities static UClass* GetAuthoritativeBlueprintClass(UBlueprint const* const Blueprint) { UClass* BpClass = (Blueprint->SkeletonGeneratedClass != nullptr) ? Blueprint->SkeletonGeneratedClass : Blueprint->GeneratedClass; if (BpClass == nullptr) { BpClass = Blueprint->ParentClass; } UClass* AuthoritativeClass = BpClass; if (BpClass != nullptr) { AuthoritativeClass = BpClass->GetAuthoritativeClass(); } return AuthoritativeClass; }
void UK2Node_Variable::CreatePinForSelf() { const UEdGraphSchema_K2* K2Schema = GetDefault<UEdGraphSchema_K2>(); // Create the self pin if (!K2Schema->FindSelfPin(*this, EGPD_Input)) { // Do not create a self pin for locally scoped variables if( !VariableReference.IsLocalScope() ) { bool bSelfTarget = VariableReference.IsSelfContext() && (ESelfContextInfo::NotSelfContext != SelfContextInfo); UClass* MemberParentClass = VariableReference.GetMemberParentClass(GetBlueprintClassFromNode()); UClass* TargetClass = MemberParentClass; // Self Target pins should always make the class be the owning class of the property, // so if the node is from a Macro Blueprint, it will hook up as self in any placed Blueprint if(bSelfTarget) { if(UProperty* Property = VariableReference.ResolveMember<UProperty>(GetBlueprintClassFromNode())) { TargetClass = Property->GetOwnerClass()->GetAuthoritativeClass(); } else { TargetClass = GetBlueprint()->SkeletonGeneratedClass->GetAuthoritativeClass(); } } else if(MemberParentClass && MemberParentClass->ClassGeneratedBy) { TargetClass = MemberParentClass->GetAuthoritativeClass(); } UEdGraphPin* TargetPin = CreatePin(EGPD_Input, K2Schema->PC_Object, TEXT(""), TargetClass, false, false, K2Schema->PN_Self); TargetPin->PinFriendlyName = LOCTEXT("Target", "Target"); if (bSelfTarget) { TargetPin->bHidden = true; // don't show in 'self' context } } } else { //@TODO: Check that the self pin types match! } }
void UK2Node_CallParentFunction::SetFromFunction(const UFunction* Function) { if (Function != NULL) { bIsPureFunc = Function->HasAnyFunctionFlags(FUNC_BlueprintPure); bIsConstFunc = Function->HasAnyFunctionFlags(FUNC_Const); UClass* OwnerClass = Function->GetOwnerClass(); FGuid FunctionGuid; if (OwnerClass != nullptr) { OwnerClass = OwnerClass->GetAuthoritativeClass(); UBlueprint::GetGuidFromClassByFieldName<UFunction>(OwnerClass, Function->GetFName(), FunctionGuid); } FunctionReference.SetDirect(Function->GetFName(), FunctionGuid, OwnerClass, /*bIsConsideredSelfContext =*/false); } }
void AActor::PostEditUndo(TSharedPtr<ITransactionObjectAnnotation> TransactionAnnotation) { CurrentTransactionAnnotation = StaticCastSharedPtr<FActorTransactionAnnotation>(TransactionAnnotation); // Check if this Actor needs to be re-instanced UClass* OldClass = GetClass(); if (OldClass->HasAnyClassFlags(CLASS_NewerVersionExists)) { UClass* NewClass = OldClass->GetAuthoritativeClass(); if (!ensure(NewClass != OldClass)) { UE_LOG(LogActor, Warning, TEXT("WARNING: %s is out of date and is the same as its AuthoritativeClass during PostEditUndo!"), *OldClass->GetName()); }; // Early exit, letting anything more occur would be invalid due to the REINST_ class return; } // Notify LevelBounds actor that level bounding box might be changed if (!IsTemplate()) { GetLevel()->MarkLevelBoundsDirty(); } // Restore OwnedComponents array if (!IsPendingKill()) { ResetOwnedComponents(); // notify navigation system UNavigationSystem::UpdateActorAndComponentsInNavOctree(*this); } else { UNavigationSystem::ClearNavOctreeAll(this); } Super::PostEditUndo(TransactionAnnotation); }
UFunction* UK2Node_BaseMCDelegate::GetDelegateSignature(bool bForceNotFromSkelClass) const { FMemberReference ReferenceToUse; if(!bForceNotFromSkelClass) { ReferenceToUse = DelegateReference; } else { UClass* OwnerClass = DelegateReference.GetMemberParentClass(this); FGuid DelegateGuid; if (OwnerClass) { UBlueprint::GetGuidFromClassByFieldName<UFunction>(OwnerClass, DelegateReference.GetMemberName(), DelegateGuid); } ReferenceToUse.SetDirect(DelegateReference.GetMemberName(), DelegateGuid, OwnerClass ? OwnerClass->GetAuthoritativeClass() : NULL, false); } UMulticastDelegateProperty* DelegateProperty = ReferenceToUse.ResolveMember<UMulticastDelegateProperty>(this); return (DelegateProperty != NULL) ? DelegateProperty->SignatureFunction : NULL; }